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


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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值