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

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

时间:2014-10-09 20:13:28      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:command   service   nagios   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邮件报警设置

标签:command   service   nagios   sendmail   邮件报警   

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

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