标签:critical server null bin gre monitor ica mail moni
#!/bin/shdate
ifconfig eth0|grep "Bcast"|awk ‘{print $2}‘|awk -F: ‘{print $2}‘
br/>MYEMAIL=allen.zhang@dbappsecurity.com.cnEOF
echo -e "\033[32m \033[0m"
sleep 2
if [ -z $1 ];then
echo -e "\033[32musage: { sh $0 nginx | mysql | list.txt }\033[0m"
echo
exit
fi
if [ -f $1 -a "$1" == list.txt ];then
for i in cat list.txt
do
COUNT=ps -ef|grep $i|grep -v service|grep -v grep|wc -l
if [ "$COUNT" -eq 0 ];then
cat >$EMAIL <<EOF
*SERVICE MONITOR*****
通知类型:告警
服务:$i
主机:$M_IPADDR
状态:告警
日期/时间:$DATE
额外信息:
CRITICAL - SERVICE MONITOR:$i IS NOT RUN,PLEASE CHECK..
EOF
dos2unix $EMAIL >>/dev/null 2>&1
echo -e "\033[32mthe $i IS NOT RUN,PLEASE CHECK..\033[0m"
mail -s "$M_IPADDR $i warning" $MYEMAIL <$EMAIL >>/dev/null 2>&1
else
echo "the $i is server 200 ok"
fi
done
else
COUNT=ps -ef|grep $1|grep -v service|grep -v grep|wc -l
if [ "$COUNT" -eq 0 ];then
cat >$EMAIL <<EOF
*SERVICE MONITOR*****
通知类型:告警
服务:$1
主机:$M_IPADDR
状态:告警
日期/时间:$DATE
额外信息:
CRITICAL - SERVICE MONITOR:$1 IS NOT RUN,PLEASE CHECK..
EOF
dos2unix $EMAIL >>/dev/null 2>&1
echo -e "\033[32mthe $1 IS NOT RUN,PLEASE CHECK..\033[0m"
mail -s "$M_IPADDR $1 warning" $MYEMAIL <$EMAIL >>/dev/null 2>&1
else
echo "the $1 is server 200 ok"
fi
fi
标签:critical server null bin gre monitor ica mail moni
原文地址:https://blog.51cto.com/1009516/2425466