Skip to content

Instantly share code, notes, and snippets.

@koy1619
Created August 11, 2020 09:15
Show Gist options
  • Save koy1619/7b18244baa4fd8c56236bf6aaea0753d to your computer and use it in GitHub Desktop.
Save koy1619/7b18244baa4fd8c56236bf6aaea0753d to your computer and use it in GitHub Desktop.
#!/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