码迷,mamicode.com
首页 > 移动开发 > 详细

nagios邮件报警设置

时间:2014-09-29 21:07:32      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:nagios   email   邮件报警   sendemail   

1、下载 sendEmail

   wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

2、配置 sendEmail

   tar zxvf sendEmail-v1.56.tar.gz

   cd sendEmail-v1.56

   cp sendEmail /usr/local/bin

   chmod 777 /usr/local/bin/sendEmail

   发送测试邮件

   /usr/local/bin/sendEmail -f test@126.com -t test@qq.com -s smtp.126.com -xu test@126.com -xp password -u "nagios" -m "tets"
解释:
-f表示发送者的邮箱
-t表示接收者的邮箱
-s表示SMTP服务器的域名或者ip
-u表示邮件的主题
-xu表示SMTP验证的用户名
-xp表示SMTP验证的密码
-m表示邮件的内容

3、配置contacts.cfg

vi /usr/local/nagios/etc/objects/contacts.cfg  输入接收报警邮箱地址

  

define contact{

        contact_name                    nagiosadmin             ; Short name of user

        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)

        alias                           Nagios Admin            ; Full name of user

        email                           test@test.com   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

        }

4、配置commands.cfg

vi /usr/local/nagios/etc/objects/commands.cfg

注解# ‘notify-host-by-email‘ command definition 与# ‘notify-service-by-email‘ command definition下所有的设置

重新输入以下内容

 

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

define command{

       command_name    notify-host-by-email

       command_line    /usr/bin/printf "%b" "***** Nagios *****\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f test@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$ is $HOSTSTATE$**"-xu test@126.com -xp password -o message-charset=utf8

       }

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

define command{

       command_name    notify-service-by-email

  command_line    /usr/bin/printf "%b" "***** Nagios *****\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f test@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$**" -xu test@126.com -xp password -o message-charset=utf8

       }

5、重启服务

nagios邮件报警设置

标签:nagios   email   邮件报警   sendemail   

原文地址:http://2860664.blog.51cto.com/2850664/1559488

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!