Copy Code code as follows:
#!/bin/bash
#2013 -01-06 14:00:00 wanggy Exp
#note:p ing Monitor
Set-u
#set-X
Ping_fun ()
{
d_network=192.168.1
Echo-n "Input" network (default $d _network): "
Read Network
: ${network:= $d _network}
echo "Network: $network"
D_hostip_beg=1
d_hostip_end=254
Echo-n "Input" HostIP (default $d _hostip_beg $d _hostip_end): "
Read Hostip_beg Hostip_end
: ${hostip_beg:= $d _hostip_beg}
: ${hostip_end:= $d _hostip_end}
echo "Hostip_beg: $hostip _beg"
echo "Hostip_end: $hostip _end"
Count=3
For ((hostip= $hostip _beg;hostip<= $hostip _end;hostip++));d o
host= $network. $hostip
echo "Starts ping detection $host"
Ping-c $count $host &>/dev/null
If [$ = 0];then
echo "$host is up"
Else
Sleep 3
Ping-c $count $host &>/dev/null
If [$ = 0];then
echo "$host is up"
Else
echo "$host is down"
Fi
Fi
Done
#echo "Execution Completed"
Exit 0
}
Main ()
{
echo "----Start the ping program----"
Ping_fun
}
Main
Exit 0