文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ping自动报警 shell脚本 for linux

ping自动报警 shell脚本 for linux

时间:2005-12-25  来源:hb2k

linux 的和solaris的居然不一样!

#!/bin/sh
PingConf='/opt/monitor/newIp'
#File where the log will be stored
LogDir='/opt/monitor/newLog'

#Define the interval time
INTERVAL='10'

#Define the alarm process

########################################################
 proc_main()
{
   while read IpAddress
   do
     #ingore any hash signs
      case $IpAddress in
      #*);;
       *)

        ping -w 20 $IpAddress -c 5  >errtmp$$
#       ping $IpAddress -c 10 >errtmp$$
       if [ $? = 0 ] ; then
               rm errtmp$$
       else
               rm errtmp$$
               ErrTime=`date +%Y/%m/%d/%H:%M:%S`
#      echo "$ErrTime"": ""$IpAddress"" cann't be connected">>$LogDir
       echo "<font color=000000>$ErrTime</font>"":""<font color=000000><B>$IpAddress<B>"" cann't be connected</font><BR> ">>$LogDir
               sleep 1
               cp /opt/monitor/newLog  /opt/OV/www/htdocs/PingLog/new.html
               sleep 1
#               mail  -s "$IpAddress"Cantreach -c 我的email  </dev/null
               play -v 50 /opt/monitor/123.au
       fi
    esac 
    done <$PingConf
  }

##########################################################
# execute the proc_main function every the specified time INTERVAL
while [ "1" -eq "1" ]
do
  
   # execute the proc_main function
     proc_main
   # suspend execution  for INTERVAL seconds
     sleep $INTERVAL
done

相关阅读 更多 +
排行榜 更多 +
马里奥赛车世界游戏手机版下载

马里奥赛车世界游戏手机版下载

赛车竞速 下载
无畏契约皮肤开箱器手游下载

无畏契约皮肤开箱器手游下载

休闲益智 下载
旭日之城官方正版下载

旭日之城官方正版下载

策略塔防 下载