Created
February 12, 2013 03:44
-
-
Save hackingbutlegal/4760097 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
function ping_nodes | |
{ | |
# set -x # Uncomment to debug this function | |
# set -n # Uncomment to check command syntax without any execution | |
if [ $PINGNODES = "TRUE" ] | |
then | |
echo # Add a single line to the output | |
# Loop through each node in the $PINGLIST | |
for HOSTPINGING in $PINGLIST # Spaces between nodes in the | |
# list is assumed | |
do | |
# Inform the user what is going On | |
echo "Pinging --> ${HOSTPINGING}...\c" | |
# If the pings received back is equal to "0" then you have a | |
# problem. | |
# Ping $PING_COUNT times, extract the value for the pings | |
# received back. | |
PINGSTAT=$(ping_host $HOSTPINGING | grep transmitted \ | |
| awk '{print $4}') | |
# If the value of $PINGSTAT is NULL, then the node is | |
# unknown to this host | |
if [[ -z "$PINGSTAT" && "$PINGSTAT" = '' ]] | |
then | |
echo "Unknown host" | |
continue | |
fi | |
if (( $PINGSTAT == 0 )) | |
then # Let's do it again to make sure it really is reachable | |
echo "Unreachable...Trying one more time...\c" | |
sleep $INTERVAL | |
PINGSTAT2=$(ping_host $HOSTPINGING | grep transmitted \ | |
| awk '{print $4}') | |
if [ $PINGSTAT2 -eq "0" ] | |
then # It REALLY IS unreachable...Notify!! | |
echo "Unreachable" | |
echo "Unable to ping $HOSTPINGING from $THISHOST" \ | |
| tee -a $PING_OUTFILE | |
else | |
echo "OK" | |
fi | |
else | |
echo "OK" | |
fi | |
done | |
fi | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment