Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

Varnish Nagios Plugin

Rumi, September 24, 2013

Install

To use this plugin you need to have varnishstat installed which is installed by default when you install varnish.

Perl is also required for this plugin. If you don’t have Perl installed you can install in by running the command below
sudo apt-get install perl
or
sudo yum install perl

Now you can download the file above and extract it:
wget <a href="http://www.toms-blog.com/wp-content/uploads/2013/07/check_varnish-v1.0.tar.gz">http://www.toms-blog.com/wp-content/uploads/2013/07/check_varnish-v1.0.tar.gz</a>
tar -xzf check_varnish-v1.0.tar.gz

Now you should have a file “check_varnish.pl” make sure that it has execute permissions:
chmod u+x check_varnish.pl

You now need to copy this file to your nagios plugins folder. You should consult your nagios config to find out where this is. Mine was ‘/usr/lib/nagios/plugin’
1 mv check_varnish.pl /usr/lib/nagios/plugins/.
How To

check_varnish.pl – Monitor and report on varnish usage

check_varnish.pl [-c|–cache] [-b|–bin <varnishstatbinary>] [-d|–backend <total|ratio>] [-s|–stats <varnish statfield>] [-t|–technique <lt|gt>] [-w|–warning <number>] [-c|–critical <number>] [-h|–help]

DESCRIPTION

This script will report on various varnish stats including: varnish cache hit ratio backend error count (Total or Ratio) Any other counter in varnishstat If no counters are required the script will ensure the varnish binary is running

OPTIONS

-a –cache – this will make the script output cache_hit ratio perfdata

-b –bin <varnishstat> – to specify a different location of the default varnishstat binary location. Default is ‘/usr/bin/varnishstat’

-d –backend <all|success|unhealthy|busy|fail|reuse|toolate|recycle|retry> – specify script to output backend data you can output ratio, total or both

-h –help – output this message

-w –warning <number> – specify the warning threshold. Required for cache and backend checks

-c –critical <number> – specify the critical threshold. Required for cache and backend checks

-s –stats <varnishstat field> – specify a comma separated list of all the stats you wish to check Critical and Warning can be specified and all values will be compared to these values.

-t –technique <lt|gt> – when specifying stats you can also specify what technique you wish to use to compare the values to the thresholds. specify lt for less than and gt for greater than. Default is gt

EXAMPLES

Check varnish is running

./check_varnish.pl

Check varnish Cache Hit Ratio and warn if ratio is below 0.8

./check_varnish.pl -a -w 0.8 -c 0.6

Check varnish Backends

./check_varnish.pl -d all

Check varnish client requests and drops

./check_varnish.pl -s client_drop,client_req
Nagios Set Up

Once you have run the command in the CLI and all is working you can add the command:
1 define command {
2 command_name check_varnish
3 command_line $USER1$/check_varnish.pl $ARG1$
4 register 1
5 }

$USER1$ is your variable pointing to your nagios plugins folder and $ARG1$ are any command line arguments you specify in the service.
1 define service {
2 host_name localhost
3 service_description Varnish
4 check_command check_varnish!–cache -w 0.6 -c 0.4
5 register 1
6 }

The service above will give a warning if the hit ratio goes below 0.6 and critical if the ratio goes below 0.4
NRPE

The below is a line that can be used in the NRPE configuration for remote monitoring:
1 command[check_varnish_cache_hit]=/usr/lib/nagios/plugins/check_varnish.pl –cache -w 0.6 -c 0.4

The NRPE service could look like this:
1 define service {
2 host_name varnishserver
3 service_description Varnish Cache Hit Ratio
4 check_command check_nrpe!check_varnish_cache_hit
5 register 1
6 }

Download the plugin

Configurations (Linux) Scripts icingaNagiosVarnish

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker endian icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx pfsense php Postfix powerdns Proxmox RDP squid SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin XCP-NG zimbra

Topics

Recent Posts

  • Install Jitsi on Ubuntu 22.04 / 22.10 April 30, 2025
  • Key Lessons in life April 26, 2025
  • Create Proxmox Backup Server (PBS) on Debian 12 April 19, 2025
  • Add Physical Drive in Proxmox VM Guest April 19, 2025
  • Mount a drive permanently with fstab in Linux April 16, 2025
  • Proxmox 1:1 NAT routing March 30, 2025
  • Installation steps of WSL – Windows Subsystem for Linux March 8, 2025
  • Enabling Nested Virtualization In Proxmox March 8, 2025
  • How to Modify/Change console/SSH login banner for Proxmox Virtual Environment (Proxmox VE / PVE) March 3, 2025
  • Install Proxmox Backup Server on Debian 12 February 12, 2025

Archives

Top Posts & Pages

  • Install Jitsi on Ubuntu 22.04 / 22.10
©2025 Bots! | WordPress Theme by SuperbThemes