Skip to content

Instantly share code, notes, and snippets.

@dev-harsh1998
Last active July 4, 2018 17:21
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 dev-harsh1998/1e06c246cb2f44cb92cec340a192b89e to your computer and use it in GitHub Desktop.
Save dev-harsh1998/1e06c246cb2f44cb92cec340a192b89e to your computer and use it in GitHub Desktop.
address=Ad.dr.es.sx
assume=1 #Assume thing is is up by default
while true
do
echo -n $(date +"%a, %b %d, %r") "-- "
ping -c 1 ${address} > /tmp/ping.$
if [[ $? -ne 0 ]]; then
if [[ ${assume} -eq 1 ]]; then #Edge trigger to be sure
echo -n "SQL Thing down"
else
echo -n "... still down"
fi
assume=0 #Finalize check
else
if [[ ${assume} -eq 0 ]]; then
echo -n "SQL back up"
fi
assume=1
fi
cat /tmp/ping.$ | head -2 | tail -1
sleep 5; # sleep for 5 second interval
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment