andybeak
4/29/2015 - 12:35 PM

Monitoring and restarting Varnish - Script from http://www.cyberciti.biz/tips/howto-linux-unix-write-to-syslog.html

Monitoring and restarting Varnish - Script from http://www.cyberciti.biz/tips/howto-linux-unix-write-to-syslog.html

#!/bin/bash

# Script from http://www.cyberciti.biz/tips/howto-linux-unix-write-to-syslog.html

result=$(echo -e "ping\n\r" | nc localhost 6082|grep PONG|wc -l);

if [ "${result}" -lt "1" ];
then
/etc/init.d/varnish stop;
sleep 5;
/etc/init.d/varnish start;
logger Varnish restart
fi

sleep 5;

results=$(echo -e "ping\n\r" | nc localhost 6082|grep PONG|wc -l);

if [ "${results}" -lt "1" ];
then
/etc/init.d/varnish stop;
sleep 5;
/etc/init.d/varnish start;
logger Second Varnish restart
fi


exit 0;