#!/bin/bash
#this program is monitor.

result=`/bin/ping -c 5 192.168.4.36 |grep 'packet loss' | awk -F 'packet loss' '{ print $1 }' | awk '{ print $NF }' | sed 's/%//g'`

sleep 7

if [ $result -eq 100 ]; then
  echo -e "this erp server is down --`date`" |mail -s "this erp server is down" yueyunfei@acme.com.cn
elif [ $result -eq 0 ];then
  echo -e "this erp server is up  --`date` "  |mail -s "Notice: this server is up " yueyunfei@acme.com.cn
else
  echo -e "this erp server is critical-- and pack loss is $result \n`date` " |mail -s 'notice: the network is critical ' yueyunfei@acme.com.cn
fi
exit 0

posted on 2017-07-21 08:02  FEX-x  阅读(421)  评论(0)    收藏  举报