热门IT资讯网

centos6.5 nagios-4.0.8 系统自带sendmail邮件报警设置

发表于:2024-11-29 作者:热门IT资讯网编辑
编辑最后更新 2024年11月29日,1、安装相关组建yum install mailx sendmail*chkconfig sendmail onservice sendmail start2、测试邮件echo "Hello Worl

1、安装相关组建

yum install mailx sendmail*

chkconfig sendmail on

service sendmail start

2、测试邮件

echo "Hello World" | mail [email protected]

3、设置发件人

[root@localhost]#vi /etc/mail.rc


set [email protected] smtp=smtp.163.com set smtp-auth-user=skykws smtp-auth-password=000000 smtp-auth=login

4、编辑command.cfg

# 'notify-host-by-email' command definition

define command{

command_namenotify-host-by-email

command_line/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

}


# 'notify-service-by-email' command definition

define command{

command_namenotify-service-by-email

command_line/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

}

4、重启nagios

service nagios restart

5、后记

关于报警发送间隔等等设置不做详细介绍

0