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!" "[email protected]"
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: [email protected]
<[email protected]>FaceTime: [email protected]
<[email protected]>*
_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to