From 00053a5397581d88f29803e3f3e01276885a97bc Mon Sep 17 00:00:00 2001 From: Conor Branagan Date: Thu, 25 Apr 2013 16:09:24 -0400 Subject: [PATCH] IIS: By default use _Total, but allow a configurable list of sites --- checks.d/iis.py | 12 +++++++++--- conf.d/iis.yaml.example | 12 ++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/checks.d/iis.py b/checks.d/iis.py index 078bdaae76..e2b0d6af05 100644 --- a/checks.d/iis.py +++ b/checks.d/iis.py @@ -50,6 +50,7 @@ def check(self, instance): user = instance.get('username', None) password = instance.get('password', None) instance_tags = instance.get('tags', []) + sites = instance.get('sites', ['_Total']) w = wmi.WMI(host, user=user, password=password) try: @@ -62,11 +63,16 @@ def check(self, instance): # Iterate over every IIS site for iis_site in wmi_cls: - # Skip the aggregate value - if iis_site.Name == '_Total': + # Skip any sites we don't specifically want. + if iis_site.Name not in sites: continue - tags = instance_tags + ['site:%s' % iis_site.Name] + # Tag with the site name if we're not using the aggregate + if iis_site.Name != '_Total': + tags = instance_tags + ['site:%s' % iis_site.Name] + else: + tags = instance_tags + for metric, mtype, wmi_val in self.METRICS: if not hasattr(iis_site, wmi_val): self.log.error('Unable to fetch metric %s. Missing %s in Win32_PerfFormattedData_W3SVC_WebService' \ diff --git a/conf.d/iis.yaml.example b/conf.d/iis.yaml.example index c14ca2f97b..1ec05d0b1a 100644 --- a/conf.d/iis.yaml.example +++ b/conf.d/iis.yaml.example @@ -4,14 +4,20 @@ init_config: instances: # By default, this check will run against a single instance - the current # machine that the Agent is running on. It will check the WMI performance - # counters for IIS on that machine. + # counters for IIS on that machine. # # If you want to check other remote machines as well, you can add one # instance per host. Note: If you also want to check the counters on the # current machine, you will have to create an instance with empty params. # + # The `sites` parameter allows you to specify a list of sites you want to + # read metrics from. With sites specified, metrics will be tagged with the + # site name. If you don't define any sites, the check will pull the + # aggregate values across all sites. + # # Here's an example of configuration that would check the current machine - # and a remove machine called MYREMOTESERVER (with optional tags): + # and a remote machine called MYREMOTESERVER. For the remote host we are + # only pulling metrics from the default site. # #- host: . # "." means the current host # tags: @@ -23,3 +29,5 @@ instances: # tags: # - myapp2 # - east + # sites: + # - Default Web Site