Last active
July 4, 2018 17:21
-
-
Save dev-harsh1998/1e06c246cb2f44cb92cec340a192b89e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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