资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

nagios邮件报警配置-创新互联

搭建nagios的目的就是为了他的报警系统,nagios据我所了解可以有三种报警:
一、声音报警
二、电子邮件报警
三、手机短讯报警
下面是我的邮件报警的配置过程:
1、开启系统自带的sendmail邮件系统
service sendmail start
如果没有安装,可以yum一下
yum install -y sendmail*
service sendmail restart
测试发送邮件:
echo "test" | mail lihuipeng007@163.com
我系统在关掉iptables和selinux前提下是正常的
2、配置nagios中报警邮箱
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                           lihuipeng007@163.com   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
在email那里加上自己的邮箱,如果有多个可以用逗号隔开
3、设置报警方式:
vi /usr/local/nagios/etc/objects/templates.cfg
define contact{
name                           generic-contact        ; The name of this contact template
service_notification_period    24x7                   ; service notifications can be sent anytime
host_notification_period       24x7                   ; host notifications can be sent anytime
service_notification_options   w,u,c,r,f,s            ; send notifications for all service states, flapping events, and scheduled downtime events
 host_notification_options      d,u,r,f,s              ; send notifications for all host states, flapping events, and scheduled downtime events
service_notification_commands  notify-service-by-email ; send service notifications via email
host_notification_commands     notify-host-by-email   ; send host notifications via email
register                       0                      ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}
这两个notify-service-by-email 和 notify-host-by-email   是在command.cfg那里定义的,看看是怎么定义的:
# 'notify-host-by-email' command definition
define command{
command_name   notify-host-by-email
 command_line   /usr/bin/printf "%b" "***** Nagios ***** Notification Type: $NOTIFICATIONTYPE$ Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$ " | /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 ***** Notification Type: $NOTIFICATIONTYPE$ Service: $SERVICEDESC$ Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$ Additional Info: $SERVICEOUTPUT$ " | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
这里已经默认配置好,我们不用修改直接调用就是了
最后重启服务:
service nagios retart
然后随便关掉一些服务测试一下效果!

创新互联公司主要从事成都网站设计、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务江西,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站栏目:nagios邮件报警配置-创新互联
标题链接:http://cdkjz.cn/article/pcchh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220