Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conor/windows services #1225

Merged
merged 7 commits into from
Dec 22, 2014
Merged

Conor/windows services #1225

merged 7 commits into from
Dec 22, 2014

Conversation

whatarthurcodes
Copy link
Contributor

conorbranagan and others added 2 commits August 11, 2014 21:10
The check will submit a metric tagged by service name that has a value
depending on the state of the service. We could extend this check to
provide more information later on.
wmi_service = results[0]
self._collect_metrics(wmi_service, tags)

def _collect_metrics(self, wmi_service, custom_tags):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should probably be renamed, we are not sending metrics anymore

@remh
Copy link
Contributor

remh commented Nov 26, 2014

Looks great besides the nitpick comments i made!

I don't think it's the case but do you think it's possible to write an interesting test for that ?

"""
tags = [u'service:%s' % wmi_service.Name]
tags.extend(custom_tags)
state_value = self.STATE_TO_VALUE.get(wmi_service.State, -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about defaulting to AgentCheck.UNKNOWN instead of -1 which doesn't map to a status?

@whatarthurcodes
Copy link
Contributor Author

What do you mean by interesting test? From my knowledge on windows services, it seems every is accounted for? Unless @conorbranagan knows of some weird things that might happen?

@remh
Copy link
Contributor

remh commented Nov 26, 2014

The goal of adding tests is to prevent things from getting broken in the future.

But testing that specific feature is not straight forward as we can't easily mock windows services.

""" Given an instance of a wmi_object from Win32_Service, write any
performance counters to be gathered and flushed by the collector.
"""
tags = [u'service:%s' % wmi_service.Name]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tags should probably include the host (and if it's "." (current host) then replace by the agent hostname)

performance counters to be gathered and flushed by the collector.
"""
if host == ".":
host_name = self.hostname
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot the:

else:
    host_name = host

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup i did thanks

self.wmi_conns = {}

def _get_wmi_conn(self, host, user, password):
key = "%s:%s:%s" % (host, user, password)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to not hash the password in the key here, you cannot have 1 user for several password anyway I guess, but it's maybe nitpicky.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whatarthurcodes could you sort this out, so we can merge it for 5.2!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LeoCavaille did my change reflect your concern?

@LeoCavaille
Copy link
Member

@whatarthurcodes 👍

remh added a commit that referenced this pull request Dec 22, 2014
@remh remh merged commit 59bcbd3 into master Dec 22, 2014
@remh remh deleted the conor/windows_services branch January 14, 2015 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants