频道栏目
首页 > 资讯 > 浏览器 > 正文

服务器自动发送邮件监测freeswitch进程

15-06-10        来源:[db:作者]  
收藏   我要投稿
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

相关TAG标签
上一篇:win7下安装Mysql开机自启动
下一篇:运维角度浅谈:MySQL数据库优化
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站