Skip to content

Instantly share code, notes, and snippets.

@peelman
Last active August 26, 2016 15:46
Show Gist options
  • Save peelman/10a6564b6906ba43738773c621b81bd4 to your computer and use it in GitHub Desktop.
Save peelman/10a6564b6906ba43738773c621b81bd4 to your computer and use it in GitHub Desktop.
#/bin/bash
IP="10.x.x.x"
#Look for number of received pings, if 0 received then restart OpenVPN service
RESULT=`ping -c 2 -W 1 $IP | grep transmitted | awk '{print $4}'`
if [ $? -ne 0 ] && [ $RESULT -eq 0 ]
then
DATE=`date`
echo "OpenVPN restart on $DATE"
service openvpn restart
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment