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

[iis] fix is_2008 option #3039

Merged
merged 1 commit into from Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion checks.d/iis.py
Expand Up @@ -73,10 +73,12 @@ def check(self, instance):
filters = map(lambda x: {"Name": tuple(('=', x))}, sites)

metrics_by_property, properties = self._get_wmi_properties(instance_key, self.METRICS, [])

if is_2008:
for idx, prop in enumerate(properties):
if prop == "TotalBytesTransferred".lower():
if prop == "TotalBytesTransferred":
properties[idx] = "TotalBytesTransfered"
break

wmi_sampler = self._get_wmi_sampler(
instance_key,
Expand Down
9 changes: 9 additions & 0 deletions tests/checks/mock/test_iis.py
Expand Up @@ -99,6 +99,15 @@ def test_check_2008(self):
self.run_check_twice(config)

# Test metrics
query = ("Select ServiceUptime,TotalBytesSent,TotalBytesReceived,TotalBytesTransfered,"
"CurrentConnections,TotalFilesSent,TotalFilesReceived,TotalConnectionAttemptsAllInstances,"
"TotalGetRequests,TotalPostRequests,TotalHeadRequests,TotalPutRequests,TotalDeleteRequests,"
"TotalOptionsRequests,TotalTraceRequests,TotalNotFoundErrors,TotalLockedErrors,TotalAnonymousUsers,"
"TotalNonAnonymousUsers,TotalCGIRequests,TotalISAPIExtensionRequests"
" from Win32_PerfFormattedData_W3SVC_WebService WHERE "
"( Name = 'Failing site' ) OR ( Name = 'Working site' ) OR ( Name = 'Default Web Site' )")

self.assertWMIQuery(query)

# Normalize site-names
default_site_name = re.sub(r"[,\+\*\-/()\[\]{}\s]", "_", config['instances'][0]['sites'][0])
Expand Down
11 changes: 7 additions & 4 deletions tests/core/test_wmi.py
Expand Up @@ -184,16 +184,19 @@ def ExecQuery(self, query, query_language, flags):
results += load_fixture("win32_perfformatteddata_w3svc_webservice", ("Name", "Default Web Site")) # noqa
results += load_fixture("win32_perfformatteddata_w3svc_webservice", ("Name", "Working site")) # noqa

if query == ("Select ServiceUptime,TotalBytesSent,TotalBytesReceived,TotalBytesTransfered,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 = 'Failing site' ) OR ( Name = 'Working site' ) OR ( Name = 'Default Web Site' )"): # noqa
results += load_fixture("win32_perfformatteddata_w3svc_webservice_2008", ("Name", "Default Web Site")) # noqa
results += load_fixture("win32_perfformatteddata_w3svc_webservice_2008", ("Name", "Working 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 = 'Working site' ) OR ( Name = 'Default Web Site' )"): # noqa
results += load_fixture("win32_perfformatteddata_w3svc_webservice_2008", ("Name", "Default Web Site")) # noqa
results += load_fixture("win32_perfformatteddata_w3svc_webservice_2008", ("Name", "Working Site")) # noqa

if query == ("Select Name,State from Win32_Service WHERE ( Name = 'WSService' ) OR ( Name = 'WinHttpAutoProxySvc' )"): # noqa
results += load_fixture("win32_service_up", ("Name", "WinHttpAutoProxySvc"))
results += load_fixture("win32_service_down", ("Name", "WSService"))
Expand Down