Centos 6.5 服務器下面配置郵件客戶端 發送報警郵件
以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
本文出自 “sdsca” 博客,請務必保留此出處http://sdsca.blog.51cto.com/10852974/1968208
Centos 6.5 服務器下面配置郵件客戶端 發送報警郵件