Small (hopefully helpful) script to monitor Varnish's uptime
Jennings III, Raymond
raymond.jennings at nytimes.com
Fri Jan 23 18:36:17 CET 2015
I was having a lot of segmenation faults in Varnish (due to our own
mistakes) but unless you are monitoring syslog or /var/log/kern you might
not ever know it's happening given that the child process restarts very
quickly so I wrote this little cron job:
You first have to bootstrap this right after you first install and start
varnish with:
/usr/bin/varnishstat -1 | /bin/grep 'uptime' | /bin/awk '{ print $2}'
>/var/nyt/logs/varnish/varnish_uptime
The cron job is:
#!/bin/bash
new_varnish_uptime=`/usr/bin/varnishstat -1 | /bin/grep 'uptime' | /bin/awk
'{ print $2}'`
old_varnish_uptime=`cat /var/nyt/logs/varnish/varnish_uptime`
delta_time=$(echo "$new_varnish_uptime - $old_varnish_uptime" | /usr/bin/bc)
if [[ $delta_time -lt 0 ]]; then
echo "Uh oh!!! Varnish was restarted. It's uptime is now
$new_varnish_uptime and it used to be $old_varnish_uptime." | /bin/mail -s
"Varnish Server Restarted!" "Raymond.Jennings at nytimes.com"
fi
echo $new_varnish_uptime >/var/nyt/logs/varnish/varnish_uptime
There is a race condition if Varnish is restarting faster than the
frequency of the cron job running.
Raymond Jennings III
*nytimes.com <http://nytimes.com/>*
*Office: 212.556.7786 <212-556-7786>*
*iPhone: 914.330.5074 <914-330-5074>E-mail: Raymond.Jennings at nytimes.com
<Raymond.Jennings at nytimes.com>FaceTime: Raymond.Jennings at nytimes.com
<Raymond.Jennings at nytimes.com>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20150123/795acfcd/attachment.html>
More information about the varnish-misc
mailing list