This is a Zabbix template + discovery & sender script useful to monitor Varnish Cache >= 4.0 instances:
Copy
zabbix-varnish-cache.pyto/usr/local/bin/.If using Varnish Cache >= 4.1, add
zabbixuser to thevarnishgroup:$ sudo usermod -a --groups varnish zabbix
Grant sudo permissions to the
zabbixuser to execute the/usr/local/bin/zabbix-varnish-cache.pyscript. This is not mandatory but it's recommended in order to let the script executevarnishadmcommands used to discover the current active VCL, discover healthiness of each backend, etc.Add the
varnish.discoveryuser parameter to Zabbix:UserParameter=varnish.discovery[*],sudo /usr/local/bin/zabbix-varnish-cache.py -i '$1' discover $2
Add a new job to the
zabbixuser crontab (beware of the-iand-soptions). This will submit Varnish Cache metrics through Zabbix Sender:* * * * * /usr/local/bin/zabbix-varnish-cache.py -i '' send -c /etc/zabbix/zabbix_agentd.conf -s dev > /dev/null 2>&1
Import the Varnish Cache template (
template-app-varnish.xmlfile).Add an existing / new host to the
Varnish Cache serversgroup and link it to theTemplate App Varnish Cachetemplate. Beware you must set a value for the{$VARNISH_CACHE_LOCATIONS}macro (comma-delimited list of Varnish Cache instance names). Usually you should leave its value blank when running a single Varnish Cache instance per server.Adjust triggers and trigger prototypes according with your preferences.