postfix 自动报警

先检查系统是否有默认安装  sendmail
ps -ef | grep sendmail
如果有则停掉
service sendmail stop
chkconfig sendmail off
安装 postfix
yum -y install postfix*
vi /etc/postfix/main.cf
myhostname = mail.luoyongjie.cn
mydomain = luoyongjie.cn
myorigin = $myhostname
myorigin = $mydomain
inet_interfaces = all
mynetworks = 0.0.0.0/0, 127.0.0.0/8
relay_domains = $mydestination
service postfix start //开启进程
pstree | grep master //查看进程是否开启
chkconfig postfix on //开机自动启动
alternatives –config mta  查看系统默认邮件系统
修改为2
修改dovecot配置文件
vi /etc/dovecot.conf
protocols = imap imaps pop3 pop3s
service dovecot start
chkconfig dovecot on
 
apache 自动报警脚本

#!/bin/bash
#apache.sh
nc -w2 localhost 80
if [ $? -ne 0 ]
then
        echo "apache is down"|mail user1@luoyongjie.cn -s "apache is down"
        /usr/local/apache2/bin/apachectl restart
fi

mysql 同理
#disk.sh
num=`df |awk ‘NR==2{print int($5)}’`
of [ $num -qt 80]
then
echo “disk space is ${num}%,now”|mail user@luoyongjie.cn -s “disk space >xx”
fi
最后加入crontab里面,每隔5分钟运行一次

发表评论