#! /bin/bash
. /home/dd.sh
count=`ping -c 7 -W 3 192.168.9.10|grep "time="|egrep -v "DUP" |wc -l`
echo ${count}
function output_notify {
text=$1
result=$(send_notify $text)
echo "$(date) : $result" >> /home/ip.log
}
if [ $count -lt 3 ]
then
$(output_notify "服务器ip:192.168.9.10ping不通,请关注")
sleep 3
else
echo "$(date) : 服务器ip:192.168.9.10 ping is ok" >> /home/ip.log
fi
cat dd.sh
#! /bin/bash
function send_notify {
keyword="关键字"
curl 'https://oapi.dingtalk.com/robot/send?access_token=xxxxx' \
-H 'Content-Type: application/json' \
-d '{
"msgtype": "text",
"text": { "content": "'$keyword':'$1'"}
}'
}