Created
January 10, 2017 01:15
-
-
Save sasha42/ddd6157df47330fa9c3858ae62150e5e 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
#!/bin/bash | |
# pings 8.8.8.8 and local router, saves into log if offline with timestamp | |
HOSTS="8.8.8.8 192.168.1.1" | |
COUNT=4 | |
for myHost in $HOSTS | |
do | |
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }') | |
if [ $count -eq 0 ]; then | |
# 100% failed | |
echo "Host : $myHost is down (ping failed) at $(date)" > pingdownlog.txt | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment