标签:freeswitch linux
vim /etc/mail.rc 添加
set from=******@163.com smtp=smtp://smtp.163.com:25
set smtp-auth-user=******@163.com smtp-auth-password=****** smtp-auth=login
vim check.sh
#!/bin/bash
source .bash_profile
pip=101.251.251.92
ip=`/sbin/ifconfig eth0 | grep "inet addr" | awk ‘{print $2}‘ | awk -F: ‘{print $2}‘`
i=`ps -ef | grep freeswitch | grep -v grep | wc -l`
date=`date`
cpu=`top -b -n 1 | grep Cpu | awk ‘{print $2}‘| cut -f 1 -d "%"`
ping=`ping -c 3 $pip|awk ‘NR==7 {print $4}‘`
if [ $ping -eq 0 ]
then
text2="$pip status GRASHED"
else
text2="$pip status READY"
fi
if [ $i -lt 1 ]
then
text=‘Freeswitch is down‘
echo "Server: "$ip$‘\n‘$date$‘\n‘"CPU used: "$cpu$‘\n‘"$text2"$‘\n‘"$text"| mail -s "$ip Abnormal" -a /home/freeswitch/log/freeswitch.log ******@qq.com
#else
#text=‘Freeswitch is running...‘
#echo "Server: "$ip$‘\n‘$date$‘\n‘"CPU used: "$cpu$‘\n‘"$text2"$‘\n‘"$text"| mail -s "$ip Normal" ******@qq.com
fi
设置每天8-23点,每隔一小时自动执行脚本发送邮件
crontab -e
0 8-23 * * * /root/check.sh
服务器自动发送邮件监测freeswitch进程
标签:freeswitch linux
原文地址:http://blog.csdn.net/lidecoolblue/article/details/46427749