以Centos 系统为例,确保服务器可以正常连接外网
Centos 6.5 下面默认 安装 postfix
查看
rpm -qa | grep postfix
postfix-2.6.6-2.2.el6_1.x86_64
配置邮件客户端
set [email protected]
set smtp=smtp.163.com
set [email protected]
set smtp-auth-password=UserPassword
set smtp-auth=login
发送测试邮件 echo "test" | mail -s "subject" [email protected]
登录邮箱查看邮件
应用案列,监控服务器内存每半小时检查一次
监控脚本 + 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" [email protected] < /tmp/message.txt
else
exit 1
fi
#monitor sys memory
*/30 * * * * /root/scripts/monitor.sh &> /dev/null
时间: 2024-11-06 15:17:07