Created
April 12, 2017 09:14
-
-
Save UKNC/a3b4641e19d1f93be005e4a9b96c0c0b 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 | |
hosts=(nqpc001 nqpc002 nqpc003 drft045 localhost "127.0.0.1") | |
for h in ${hosts[@]}; do | |
result=$(ping -c 2 -W 1 -q $h | grep transmitted) | |
pattern="0 received"; | |
if [[ $result =~ $pattern ]]; then | |
echo "$h is down" | |
else | |
echo "$h is up" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment