国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Linux > 正文

ping發(fā)現(xiàn)掉包報(bào)警的shell代碼

2019-10-26 18:35:20
字體:
供稿:網(wǎng)友
代碼如下:
#!/bin/bash
PING=`which ping`
DATE=`date +%Y%m%d%H%M`
TAIL=`which tail`
LOG=./ping$DATE.log
HOSTS="selboo.com.cn 221.130.191.97"
COUNT=200
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep ‘loss' | awk -F',' '{ print $3 }' | awk -F “%” ‘{ print $1 }')
if [ $count -ge 10 ]; then
/bin/echo selboo | mutt -s "$myHost pingispacketloss>10% $DATE" root@selboo.com.cn
fi
done
exit 0

復(fù)制上以上內(nèi)容為ping.sh加入crontab中讓其10分鐘跑一次,其中發(fā)郵件程序?yàn)閙utt

以下是補(bǔ)充:

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 "$ErrTime"":""$IpAddress"" cann't be connected
">>$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
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 福鼎市| 陇南市| 林口县| 平度市| 任丘市| 明溪县| 凤山县| 南投市| 孙吴县| 景德镇市| 高邑县| 长春市| 东光县| 壤塘县| 合江县| 如东县| 娱乐| 安溪县| 措美县| 卢氏县| 威信县| 泰来县| 财经| 金山区| 高邮市| 宿州市| 博爱县| 会东县| 平远县| 恩平市| 江口县| 孟州市| 定襄县| 清河县| 刚察县| 华蓥市| 托克托县| 丹凤县| 绍兴县| 安国市| 延庆县|