Skip to content

Commit

Permalink
IIS: By default use _Total, but allow a configurable list of sites
Browse files Browse the repository at this point in the history
  • Loading branch information
conorbranagan committed Apr 25, 2013
1 parent 7d6538d commit 00053a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 9 additions & 3 deletions checks.d/iis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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' \
Expand Down
12 changes: 10 additions & 2 deletions conf.d/iis.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -23,3 +29,5 @@ instances:
# tags:
# - myapp2
# - east
# sites:
# - Default Web Site

0 comments on commit 00053a5

Please sign in to comment.