#!/bin/bash
CHOSE=`ping -c 5 $1 |grep out |uniq -c |awk '{print $1}'` #uniq找獨一無二的目標
if [ $CHOSE -ge 3 ]
then
mail -s ERROR yourself@yourself.domain -v <ERROR # 此為導入的檔案
else
echo 'OK'
fi
CHOSE=`ping -c 5 $1 |grep out |uniq -c |awk '{print $1}'` #uniq找獨一無二的目標
if [ $CHOSE -ge 3 ]
then
mail -s ERROR yourself@yourself.domain -v <ERROR # 此為導入的檔案
else
echo 'OK'
fi
請把此程式 存成 假設 001.sh,
使用方式 ./001.sh [檢測IP]
會自動 ping 5 次,當超過 或者 等於 3 次,
是 Request timed out.
就會自動寄信給 yourself@yourself.domain(當然您得自己改這個 E-mail),
如果沒有,
則回報 OK
沒有留言:
張貼留言