Fixes WMI related checkers

Adds computer argument to the WMI constructor used in the
iis and wmi_check checkers. This way, they are compatible
with both WMI and PyMI (which is a faster, better alternative
to WMI).
Fixes bug in the wmi_check, where a private method was called with
fewer arguments that it should.

Partially-Implements: blueprint add-windows-support

Change-Id: I54688b096b750a46fdefae5918ec23b47987413e
This commit is contained in:
Claudiu Belu 2016-08-23 15:34:41 +03:00
parent 901b448b54
commit 2d445c19e4
2 changed files with 5 additions and 3 deletions

View File

@ -52,7 +52,8 @@ class IIS(AgentCheck):
def _get_wmi_conn(self, host, user, password):
key = "%s:%s:%s" % (host, user, password)
if key not in self.wmi_conns:
self.wmi_conns[key] = wmi.WMI(host, user=user, password=password)
self.wmi_conns[key] = wmi.WMI(computer=host, user=user,
password=password)
return self.wmi_conns[key]
def check(self, instance):

View File

@ -25,7 +25,8 @@ class WMICheck(AgentCheck):
def _get_wmi_conn(self, host, user, password):
key = "%s:%s:%s" % (host, user, password)
if key not in self.wmi_conns:
self.wmi_conns[key] = wmi.WMI(host, user=user, password=password)
self.wmi_conns[key] = wmi.WMI(computer=host, user=user,
password=password)
return self.wmi_conns[key]
def check(self, instance):
@ -56,7 +57,7 @@ class WMICheck(AgentCheck):
results = w.query(wql)
else:
results = getattr(w, wmi_class)(**f)
self._extract_metrics(results, metrics, tag_by)
self._extract_metrics(results, metrics, tag_by, instance)
else:
results = getattr(w, wmi_class)()
self._extract_metrics(results, metrics, tag_by, instance)