nagios——邮件报警
2011-05-31 19:49
246 查看
nagios搭建请看:Nginx平台安装Nagios监控服务
nagios配置请看:nagios配置——添加linux主机监控
搭建nagios的目的就是为了他的报警系统,nagios据我所了解可以有三种报警:
一、声音报警
二、电子邮件报警
三、手机短讯报警
下面是我的邮件报警的配置过程:
1、开启系统自带的sendmail邮件系统
如果没有安装,可以yum一下
测试发送邮件:
我系统在关掉iptables和selinux前提下是正常的
2、配置nagios中报警邮箱
在email那里加上自己的邮箱,如果有多个可以用逗号隔开
3、设置报警方式:
这两个notify-service-by-email 和 notify-host-by-email 是在command.cfg那里定义的,看看是怎么定义的:
这里已经默认配置好,我们不用修改直接调用就是了
最后重启服务:
然后随便关掉一些服务测试一下效果!很简单吧~
nagios配置请看:nagios配置——添加linux主机监控
搭建nagios的目的就是为了他的报警系统,nagios据我所了解可以有三种报警:
一、声音报警
二、电子邮件报警
三、手机短讯报警
下面是我的邮件报警的配置过程:
1、开启系统自带的sendmail邮件系统
service sendmail start |
yum install -y sendmail* service sendmail restart |
echo "test" | mail lihuipeng007@163.com |
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 ****** } |
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-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$ } |
最后重启服务:
service nagios retart |
相关文章推荐
- nagios监控服务出现FLAPPING状态时无法发出邮件报警信息
- linux上nagios3 短信+邮件报警
- 用escalations.cfg来限制 nagios 邮件 短信 报警发送次数
- nagios用第三方邮件服务器发送报警邮件
- 总结nagios邮件报警(mutt+msmtp)不能发邮件的原因
- yum搭建nagios监控linux&&window及邮件报警
- nagios与sendEmail结合实现邮件报警
- Nagios邮件报警、短信报警配置
- nagios邮件报警设置
- nagios邮件报警记录
- linux mail 使用外部smtp服务器实现nagios邮件报警
- nagios配置邮件报警
- nagios邮件报警脚本
- 【6】nagios从零学习使用 - centreon发送邮件报警
- nagios不能发送报警邮件
- linux mail 使用外部smtp服务器实现nagios邮件报警
- nagios-3种报警方式–声音–email/邮件—短信
- Nagios使用mutt发用报警邮件
- nagios 邮件报警脚本
- nagios用mutt发送报警邮件