Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pymunin/plugins/varnishstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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()

Expand Down
8 changes: 3 additions & 5 deletions pysysinfo/varnish.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@
__status__ = "Development"


# Defaults
varnishstatCmd = "varnishstat"



class VarnishInfo:
"""Class to retrieve stats from Varnish Cache."""

_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.
(Defaults to hostname.)
"""
self._instance = instance

self._statCmd = statCmd or 'varnishstat'

def getStats(self):
"""Runs varnishstats command to get stats from Varnish Cache.
Expand All @@ -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)
Expand Down