From 06d6e502646fd98cbdd6dc8afa91f0ad1ff933cc Mon Sep 17 00:00:00 2001 From: Harald Friessnegger Date: Wed, 7 Aug 2013 15:41:51 +0200 Subject: [PATCH] allow to set path to varnishstats --- pymunin/plugins/varnishstats.py | 6 +++++- pysysinfo/varnish.py | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pymunin/plugins/varnishstats.py b/pymunin/plugins/varnishstats.py index 47c8ce8..f0462e0 100755 --- a/pymunin/plugins/varnishstats.py +++ b/pymunin/plugins/varnishstats.py @@ -5,6 +5,7 @@ Requirements - Access to varnishstat executable for retrieving stats. + (if it's not in the PATH, provide it as environment variable) Wild Card Plugin - No @@ -27,6 +28,8 @@ instance: Name of the Varnish Cache instance. (Defaults to hostname.) + stats_command Path to varnishstat + (Defaults to 'varnishstat') include_graphs: Comma separated list of enabled graphs. (All graphs enabled by default.) exclude_graphs: Comma separated list of disabled graphs. @@ -83,8 +86,9 @@ def __init__(self, argv=(), env=None, debug=False): MuninPlugin.__init__(self, argv, env, debug) self._instance = self.envGet('instance') + self._varnishStatCmd = self.envGet('stats_command') self._category = 'Varnish' - varnish_info = VarnishInfo(self._instance) + varnish_info = VarnishInfo(self._instance, self._varnishStatCmd) self._stats = varnish_info.getStats() self._desc = varnish_info.getDescDict() diff --git a/pysysinfo/varnish.py b/pysysinfo/varnish.py index 4b7138b..83f0c8f 100644 --- a/pysysinfo/varnish.py +++ b/pysysinfo/varnish.py @@ -17,9 +17,6 @@ __status__ = "Development" -# Defaults -varnishstatCmd = "varnishstat" - class VarnishInfo: @@ -27,7 +24,7 @@ class VarnishInfo: _descDict = {} - def __init__(self, instance=None): + def __init__(self, instance=None, statCmd=None): """Initialization for monitoring Varnish Cache instance. @param instance: Name of the Varnish Cache instance. @@ -35,6 +32,7 @@ def __init__(self, instance=None): """ self._instance = instance + self._statCmd = statCmd or 'varnishstat' def getStats(self): """Runs varnishstats command to get stats from Varnish Cache. @@ -43,7 +41,7 @@ def getStats(self): """ info_dict = {} - args = [varnishstatCmd, '-1'] + args = [self._statCmd, '-1'] if self._instance is not None: args.extend(['-n', self._instance]) output = util.exec_command(args)