Repository: DataDog/dd-agent

Issue:
[iis] Non-digit value in WMI metric name
Getting this warning in v5.7.1 and `iis.site_up` is permanently triggered.

```
2016-03-16 14:57:40 GMT Standard Time | WARNING | checks.iis(iis.py:127) | When extracting metrics with WMI, found a non digit value for property 'name'.
```

This was working fine in v5.6.1



Discussion:
Hi @mausch, thanks for opening this issue!

As far as I know this warning is not related to the change in the `iis.site_up` service check behavior.

To help us troubleshoot this, could you set the `log_level` to `DEGUB` in `datadog.conf`, restart the agent and send us a flare please: https://help.datadoghq.com/hc/en-us/articles/204991415-Send-logs-and-configs-to-Datadog-via-flare-command

Thanks!

Done, internal case id is 48267

@olivielpeau case id has been updated to 48283, @kwwalter is assigned


Resolving patch:
diff --git a/checks.d/iis.py b/checks.d/iis.py
--- a/checks.d/iis.py
+++ b/checks.d/iis.py
@@ -151,9 +151,6 @@ def _submit_events(self, wmi_sampler, sites):
 
         for wmi_obj in wmi_sampler:
             sitename = wmi_obj['Name']
-            if sitename == "_Total":
-                continue
-
             uptime = wmi_obj["ServiceUptime"]
             status = AgentCheck.CRITICAL if uptime == 0 else AgentCheck.OK
 


Test patch:
diff --git a/tests/checks/mock/test_iis.py b/tests/checks/mock/test_iis.py
--- a/tests/checks/mock/test_iis.py
+++ b/tests/checks/mock/test_iis.py
@@ -9,6 +9,11 @@
 class IISTestCase(AgentCheckTest, TestCommonWMI):
     CHECK_NAME = 'iis'
 
+    WIN_SERVICES_MINIMAL_CONFIG = {
+        'host': ".",
+        'tags': ["mytag1", "mytag2"]
+    }
+
     WIN_SERVICES_CONFIG = {
         'host': ".",
         'tags': ["mytag1", "mytag2"],
@@ -97,4 +102,19 @@ def test_check_2008(self):
         self.assertServiceCheck('iis.site_up', status=AgentCheck.CRITICAL,
                                 tags=["site:{0}".format(fail_site_name)], count=1)
 
+    def test_check_without_sites_specified(self):
+        """
+        Returns the right metrics and service checks for the `_Total` site
+        """
+        # Run check
+        config = {
+            'instances': [self.WIN_SERVICES_MINIMAL_CONFIG]
+        }
+        self.run_check_twice(config)
+
+        for mname in self.IIS_METRICS:
+            self.assertMetric(mname, tags=["mytag1", "mytag2"], count=1)
+
+        self.assertServiceCheck('iis.site_up', status=AgentCheck.OK,
+                                tags=["site:{0}".format('Total')], count=1)
         self.coverage_report()
diff --git a/tests/core/test_wmi.py b/tests/core/test_wmi.py
--- a/tests/core/test_wmi.py
+++ b/tests/core/test_wmi.py
@@ -175,6 +175,12 @@ def ExecQuery(self, query, query_language, flags):
                      "TotalISAPIExtensionRequests from Win32_PerfFormattedData_W3SVC_WebService WHERE ( Name = 'Failing site' ) OR ( Name = 'Default Web Site' )"):  # noqa
             results += load_fixture("win32_perfformatteddata_w3svc_webservice", ("Name", "Default Web Site"))  # noqa
 
+        if query == ("Select ServiceUptime,TotalBytesSent,TotalBytesReceived,TotalBytesTransferred,CurrentConnections,TotalFilesSent,TotalFilesReceived,"  # noqa
+                     "TotalConnectionAttemptsAllInstances,TotalGetRequests,TotalPostRequests,TotalHeadRequests,TotalPutRequests,TotalDeleteRequests,"  # noqa
+                     "TotalOptionsRequests,TotalTraceRequests,TotalNotFoundErrors,TotalLockedErrors,TotalAnonymousUsers,TotalNonAnonymousUsers,TotalCGIRequests,"  # noqa
+                     "TotalISAPIExtensionRequests from Win32_PerfFormattedData_W3SVC_WebService WHERE ( Name = '_Total' )"):  # noqa
+            results += load_fixture("win32_perfformatteddata_w3svc_webservice", ("Name", "_Total"))  # noqa
+
         if query == ("Select * from Win32_PerfFormattedData_W3SVC_WebService WHERE ( Name = 'Failing site' ) OR ( Name = 'Default Web Site' )"):  # noqa
             results += load_fixture("win32_perfformatteddata_w3svc_webservice_2008", ("Name", "Default Web Site"))  # noqa