Fixing check_varnish monitoring plugin for Varnish 6.5 and newer releases

Written by - 0 comments

Published on - last updated on June 5th 2024 - Listed in Monitoring Varnish

On all my environments with Varnish Cache (or the commercial Varnish Enterprise) I use the monitoring plugin, which allows to monitor a Varnish process and retrieve Varnish-internal stats (using varnishstat).

This allows to create very helpful graphs, for example to show the growth of HIT vs MISS requests:

Plugin error when using Varnish Cache 6.5 or later

However after upgrading to Varnish Cache 6.5, check_varnish users would see an error message like this:

root@varnish:~# /usr/lib/nagios/plugins/ -f MAIN.n_lru_nuked,MAIN.cache_hit,MAIN.cache_miss
Traceback (most recent call last):
  File "/usr/lib/nagios/plugins/", line 158, in <module>
  File "/usr/lib/nagios/plugins/", line 152, in getopts
AttributeError: 'int' object has no attribute 'replace'

The reason for this is that the varnishstat (JSON) output has changed compared to the older versions. The stats counters are now nested under 'counters'.

To cope with this situation, a new parameter (-v / --version) was added to This allows the user to define which Varnish version is used for the check (maybe I'll replace this one day with an autodetection), handling the JSON output differently:

    if varnishversion >= 65:

How to use check_varnish with Varnish 6.5 and newer

A pull request for handling Varnish 6.5 was created in Olivier's repository. Until this is merged, the new version (v1.7) can be downloaded from my GitHub fork.

To use the plugin with Varnish 6.5 and later, use the -v / --version parameter (the plugin assumes the Varnish version is 6.0):

root@varnish:~# /usr/lib/nagios/plugins/ -f MAIN.n_lru_nuked,MAIN.cache_hit,MAIN.cache_miss -v 6.5
VARNISH OK - MAIN.n_lru_nuked is 0 - MAIN.cache_hit is 344535 - MAIN.cache_miss is 368730 -  | MAIN.n_lru_nuked=0;0;0;; MAIN.cache_hit=344535;0;0;; MAIN.cache_miss=368730;0;0;;

Which varnishstat fields should be monitored?

If you're new to Varnish monitoring and want to know which fields from the varnishstat output are worth being monitored (and graphed), check out my article from February 2020: Monitoring Varnish with check_varnish from multiple varnishstat fields.

Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder