Last active
December 12, 2015 08:28
-
-
Save dbalan/4743794 to your computer and use it in GitHub Desktop.
Tests pings.
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 | |
if [ $# != 2 ]; then | |
echo "USAGE: " ${0}" ip-addr warning-level" ; | |
exit; | |
fi | |
timeout 3 ping -c 1 $1 > /tmp/out | |
if [ $? -ne 0 ]; then | |
echo "CRITICAL -"${1}" is DOWN’" | |
exit -1 | |
else | |
delay=$(grep time /tmp/out |head -n -1|awk '{print $7}'|cut -d = -f2)" ms" | |
if [[ $delay > $2 ]]; then | |
delay=$delay"> "$2 | |
echo -n "WARNING" | |
else | |
echo -n "OK" | |
fi | |
echo "-"" " ${1} " is UP - Delay" $delay | |
rm /tmp/out | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment