首页 > 代码库 > centos6.5 nagios-4.0.8   系统自带sendmail邮件报警设置

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

1、安装相关组建

   yum install mailx sendmail*

   chkconfig sendmail on

   service sendmail start

2、测试邮件

   echo "Hello World" | mail abc@abc.com   

3、编辑command.cfg

   

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

define command{

command_name notify-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_name notify-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、后记

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

本文出自 “linux相关分享” 博客,请务必保留此出处http://2860664.blog.51cto.com/2850664/1561778

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