nagios-nrpe: add varnish check and tags

This commit is contained in:
Victor LABORIE 2017-05-17 10:32:39 +02:00
parent 50db09a88e
commit 01bb987fb3
3 changed files with 95 additions and 1 deletions

View file

@ -0,0 +1,89 @@
#!/bin/bash
#
# check_varnish_health
#
# A nagios plugin to check the health status of a varnish web cache using varnishadm.
# by rudi kramer
# Copyright 2010 rudi Kramer <rudi(dot)kramer(at)gmail(dot)com>, BSD-style copyright and disclaimer.
#
# version 1.1 - Fixed bug where backend server is not called default
#
# Command Line Usage: ./check_varnish_health -i <ip> -p <port>
#
# Example: ./check_varnish_health -i 127.0.0.1 -p 6082
#
#################################################################################
PATH=/sbin:/bin:/usr/sbin:/usr/bin
E_SUCCESS="0"
E_WARNING="1"
E_CRITICAL="2"
E_UNKNOWN="3"
PROGNAME=`basename $0`
CHECK_VARNISHD=`ps ax| grep varnishd| grep -v grep`
print_help() {
echo ""
echo "This plugin checks the health status of a varnish web cache using varnishadm"
echo ""
echo "Usage: $PROGNAME -i <ip address> -p <port> -s <secret file> -w <maximum number of sick backends before raise a warning state> -c <same as previous but for critical state>"
echo ""
}
if [ $# -lt 10 ]; then
print_help
exit $E_UNKNOWN
fi
if [ -z "$CHECK_VARNISHD" ]; then
echo "CRITICAL: varnishd is not running, unable to check health status"
exit $E_CRITICAL
fi
while test -n "$1"; do
case "$1" in
--help | -h)
print_help
exit $E_UNKNOWN
;;
-i)
IP=$2
shift
;;
-p)
PORT=$2
shift
;;
-s)
SECRET=$2
shift
;;
-w)
WARNING=$2
shift
;;
-c)
CRITICAL=$2
shift
;;
esac
shift
done
COMMAND=`varnishadm -S $SECRET -T $IP\:$PORT debug.health 2>&1 | grep "^Backend " | grep -v "Healthy" |wc -l`
OUTPUT=`varnishadm -S $SECRET -T $IP\:$PORT debug.health 2>&1 | grep "^Backend " |tr '\n' ','`
if [ $COMMAND -lt $WARNING ]; then
echo "OK: $OUTPUT"
exit ${E_SUCCESS}
elif [ $COMMAND -lt $CRITICAL ]; then
echo "WARNING: $OUTPUT"
exit ${E_WARNING}
else
echo "CRITICAL: $OUTPUT"
exit ${E_CRITICAL}
fi

View file

@ -1,6 +1,10 @@
---
- include: debian.yml
when: ansible_os_family == "Debian"
tags:
- nagios
- include: openbsd.yml
when: ansible_os_family == "OpenBSD"
tags:
- nagios

View file

@ -45,6 +45,7 @@ command[check_redis]=/usr/lib/nagios/plugins/check_tcp -p 6379
command[check_clamd]=/usr/lib/nagios/plugins/check_clamd -H /var/run/clamav/clamd.ctl -v
command[check_ssl]=/usr/lib/nagios/plugins/check_http -f follow -I 127.0.0.1 -S -p 443 -H ssl.evolix.net -C 15,5
command[check_elasticsearch]=/usr/lib/nagios/plugins/check_http -H localhost -u /_cluster/health -p 9200 -r '"status":"red",' --invert-regex
command[check_memcached]=/usr/lib/nagios/plugins/check_tcp -H 127.0.0.1 -p 11211
# Local checks (not packaged)
command[check_mem]={{ nagios_plugins_directory }}/check_mem -f -C -w 20 -c 10
@ -57,7 +58,7 @@ command[check_drbd]={{ nagios_plugins_directory }}/check_drbd -d All -c StandAlo
command[check_mongodb_connect]={{ nagios_plugins_directory }}/check_mongodb -H localhost -P27017 -A connect
command[check_glusterfs]={{ nagios_plugins_directory }}/check_glusterfs -v all -n 0
command[check_supervisord_status]={{ nagios_plugins_directory }}/check_supervisord
command[check_memcached]=/usr/lib/nagios/plugins/check_tcp -H 127.0.0.1 -p 11211
command[check_varnish]={{ nagios_plugins_directory }}/check_varnish_health -i 127.0.0.1 -p 6082 -s /etc/varnish/secret -w 2 -c 4
# Check HTTP "many". Use this to check many websites (http, https, ports, sockets and SSL certificates).
# Beware! All checks must not take more than 10s!