Skip to content

Commit

Permalink
Merge pull request #2387 from DataDog/olivielpeau/fix-iis-service-check
Browse files Browse the repository at this point in the history
[iis] Fix service check on the `_Total` site
  • Loading branch information
olivielpeau committed Mar 28, 2016
2 parents f4c3456 + 1c3c4d7 commit ee52ed5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 0 additions & 3 deletions checks.d/iis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions tests/checks/mock/test_iis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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()
6 changes: 6 additions & 0 deletions tests/core/test_wmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ee52ed5

Please sign in to comment.