From 002098846b3304a3f3141c5ac98873427c330bca Mon Sep 17 00:00:00 2001 From: Carlo Cabanilla Date: Mon, 23 Dec 2013 15:58:36 -0500 Subject: [PATCH] varnish: allow multiple instances (fixes #490) --- checks.d/varnish.py | 4 ++++ conf.d/varnish.yaml.example | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/checks.d/varnish.py b/checks.d/varnish.py index e91f1d09d5..5123475a96 100644 --- a/checks.d/varnish.py +++ b/checks.d/varnish.py @@ -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"], @@ -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] try: proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) diff --git a/conf.d/varnish.yaml.example b/conf.d/varnish.yaml.example index 69772e7828..f1af203b70 100644 --- a/conf.d/varnish.yaml.example +++ b/conf.d/varnish.yaml.example @@ -1,6 +1,13 @@ init_config: instances: - - varnishstat: /usr/bin/varnishstat -# tags: -# - instance:production \ No newline at end of file +# - 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