Skip to content

Instantly share code, notes, and snippets.

@andybeak
Created April 29, 2015 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andybeak/7f6c9d3607bbfb6a3fc2 to your computer and use it in GitHub Desktop.
Save andybeak/7f6c9d3607bbfb6a3fc2 to your computer and use it in GitHub Desktop.
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment