大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

Nagios系统监控软件的邮件告警设置

七、邮件告警设置
nagios发警告邮件是采用本机的smtp服务,可以查看commands.cfg中关于发邮件的命令的定义,使用本机的mail命令,这就需要开启本机的smtp服务,为了安全可以在防火墙上设置拒绝其他的机器连本机的25号端口。
 
1、查看command.cfg命令参数中邮件调用的情况:
[root@localhost ]# vim /usr/local/nagios/etc/objects/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$
       }
 
2、设置接收告警邮件的地址:
[root@localhost ]# vim /usr/local/nagios/etc/objects/contacts.cfg
define contact{
       contact_name     nagiosadmin  
       use              generic-contact
       alias            Nagios Admin
       email            test@139.com (这里设置接收告警的邮件地址)
       }
 
3、打开并启动主控服务器的邮件发送服务:
[root@localhost ]# service sendmail start
[root@localhost ]# chkconfig sendmail on
 
注意邮件发送服务SMTP协议需要打开本地的“25”端口,如果防火墙有阻挡的话,要开启起来。
 

本文标题:Nagios系统监控软件的邮件告警设置
文章起源:http://dzwzjz.com/article/jdsjed.html
在线咨询
服务热线
服务热线:028-86922220
TOP