Skip to content

Commit

Permalink
varnish: allow multiple instances (fixes #490)
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo Cabanilla committed Dec 23, 2013
1 parent 6a4b855 commit 0020988
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions checks.d/varnish.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def check(self, instance):
if instance.get("varnishstat", None) is None:
raise Exception("varnishstat is not configured")
tags = instance.get('tags', [])
name = instance.get('name')

# Get the varnish version from varnishstat
output, error = subprocess.Popen([instance.get("varnishstat"), "-V"],
Expand Down Expand Up @@ -114,6 +115,9 @@ def check(self, instance):
arg = "-1"

cmd = [instance.get("varnishstat"), arg]
if name is not None:
cmd.extend(['-n', name])
tags += [u'name:%s' % name]

This comment has been minimized.

Copy link
@remh

remh Dec 23, 2013

You should avoid tags called "name" as it's pretty confusing and will collide with EC2 tags.

try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Expand Down
13 changes: 10 additions & 3 deletions conf.d/varnish.yaml.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
init_config:

instances:
- varnishstat: /usr/bin/varnishstat
# tags:
# - instance:production
# - varnishstat: (required) String path to varnishstat binary
# name: (optional) String name of varnish instance. Passed to the -n parameter of varnishstat. Will also tag each metric with this name.
# tags: (optional) Additional tags to tag each metric with
#
# Example:
#
- varnishstat: /usr/bin/varnishstat
name: myvarnishinstance
tags:
- instance:production

0 comments on commit 0020988

Please sign in to comment.