以Centos 系统为例,确保服务器可以正常连接外网
Centos 6.5 下面默认 安装 postfix
查看
rpm -qa | grep postfix
postfix-2.6.6-2.2.el6_1.x86_64
配置邮件客户端
set from=user@163.com
set smtp=smtp.163.com
set smtp-auth-user=user@163.com
set smtp-auth-password=UserPassword
set smtp-auth=login
发送测试邮件 echo "test" | mail -s "subject" user@163.com
应用案列,监控服务器内存每半小时检查一次
监控脚本 + crontab
#!/bin/bash
FreeMem=`free -m | awk 'NR==3 {print $NF}'`
Host="192.168.10.32 localhost32.localdomain"
Infor_mesage="Now $Host memory is $FreeMem"
if [ $FreeMem -lt 1200 ];then
echo $Infor_mesage | tee /tmp/message.txt
/bin/mail -s "`date +%F-%T` $Infor_mesage" user@163.com < /tmp/message.txt
else
exit 1
fi
#monitor sys memory */30 * * * * /root/scripts/monitor.sh &> /dev/null
原文链接:https://www.f2er.com/centos/375768.html