Created
August 11, 2020 09:15
-
-
Save koy1619/7b18244baa4fd8c56236bf6aaea0753d 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 | |
#********************************# | |
#2013-01-11 17:00:00 wanggy exp # | |
#note:ping monitor # | |
#********************************# | |
set -u | |
ping_fun() | |
{ | |
for host in {10.10.54.88,10.10.54.77} | |
do | |
: >pinglog | |
: >pingerrlog | |
ping_count=3 | |
{ | |
echo "开始ping检测$host" | |
ping -c $ping_count $host >/dev/null | |
if [ $? = 0 ];then | |
echo "$host is up" | |
echo "$host is up" >>pinglog | |
else | |
echo "$host is down" | |
echo "$host is down" >>pingerrlog | |
fi | |
}& | |
done | |
wait | |
} | |
main() | |
{ | |
echo "----开始执行ping程序----" | |
ping_fun | |
} | |
main | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment