summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/varnish
diff options
context:
space:
mode:
authorIlya Mashchenko <ilyamaschenko@gmail.com>2019-01-31 16:02:21 +0300
committerGitHub <noreply@github.com>2019-01-31 16:02:21 +0300
commit9c334bb2ef4b8562fe5c28dab94579288ed467c1 (patch)
tree757a6024c56275543542369db45a4b7a8b83cd94 /collectors/python.d.plugin/varnish
parenta7cd45053bde6487ea88de1b568e23319f183374 (diff)
varnish module: add instance_name option (#5264)
* add instance_name option * add timeout * minor
Diffstat (limited to 'collectors/python.d.plugin/varnish')
-rw-r--r--collectors/python.d.plugin/varnish/README.md8
-rw-r--r--collectors/python.d.plugin/varnish/varnish.chart.py24
-rw-r--r--collectors/python.d.plugin/varnish/varnish.conf4
3 files changed, 30 insertions, 6 deletions
diff --git a/collectors/python.d.plugin/varnish/README.md b/collectors/python.d.plugin/varnish/README.md
index 102a5103de..44d64efe11 100644
--- a/collectors/python.d.plugin/varnish/README.md
+++ b/collectors/python.d.plugin/varnish/README.md
@@ -64,7 +64,13 @@ It produces:
### configuration
-No configuration is needed.
+Only one parameter is supported:
+
+```yaml
+instance_name: 'name'
+```
+
+The name of the varnishd instance to get logs from. If not specified, the host name is used.
---
diff --git a/collectors/python.d.plugin/varnish/varnish.chart.py b/collectors/python.d.plugin/varnish/varnish.chart.py
index 6146ce66e0..da67815762 100644
--- a/collectors/python.d.plugin/varnish/varnish.chart.py
+++ b/collectors/python.d.plugin/varnish/varnish.chart.py
@@ -136,6 +136,8 @@ CHARTS = {
}
}
+VARNISHSTAT = 'varnishstat'
+
class Parser:
_backend_new = re.compile(r'VBE.([\d\w_.]+)\(.*?\).(beresp[\w_]+)\s+(\d+)')
@@ -172,19 +174,31 @@ class Service(ExecutableService):
ExecutableService.__init__(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = CHARTS
- varnishstat = find_binary('varnishstat')
- self.command = [varnishstat, '-1'] if varnishstat else None
+ self.instance_name = configuration.get('instance_name')
self.parser = Parser()
+ self.command = None
+
+ def create_command(self):
+ varnishstat = find_binary(VARNISHSTAT)
+
+ if not varnishstat:
+ self.error("can't locate '{0}' binary or binary is not executable by user netdata".format(VARNISHSTAT))
+ return False
+
+ if self.instance_name:
+ self.command = [varnishstat, '-1', '-n', self.instance_name, '-t', '1']
+ else:
+ self.command = [varnishstat, '-1', '-t', '1']
+ return True
def check(self):
- if not self.command:
- self.error("Can't locate 'varnishstat' binary or binary is not executable by user netdata")
+ if not self.create_command():
return False
# STDOUT is not empty
reply = self._get_raw_data()
if not reply:
- self.error("No output from 'varnishstat'. Not enough privileges?")
+ self.error("No output from 'varnishstat'. Is it running? Not enough privileges?")
return False
self.parser.init(reply)
diff --git a/collectors/python.d.plugin/varnish/varnish.conf b/collectors/python.d.plugin/varnish/varnish.conf
index 9d582f7def..54bfe4deee 100644
--- a/collectors/python.d.plugin/varnish/varnish.conf
+++ b/collectors/python.d.plugin/varnish/varnish.conf
@@ -59,4 +59,8 @@
# penalty: yes # the JOB's penalty
# autodetection_retry: 0 # the JOB's re-check interval in seconds
#
+# Additionally to the above, varnish also supports the following:
+#
+# instance_name: 'name' # the name of the varnishd instance to get logs from. If not specified, the host name is used.
+#
# ----------------------------------------------------------------------