2.3 nagios 配置邮件告警
2016-07-04 21:06
405 查看
目前nagios只能在浏览器上查看各个机器各个服务的状态,当某个机器宕掉或者某个服务宕掉时,我们是不知道的,因为我们不可能时时盯着服务看。这时,就需要用到告警系统了,让它自动化,当发现问题时及时通知我们。下面配置使用发邮件的方式来实现告警。
在服务端操作!
首先定义邮件接受者。
然后在需要告警的服务里加上contactgroup
编辑完配置文件后,重启nagios服务
在服务端操作!
首先定义邮件接受者。
[root@localhost ~]# vim /etc/nagios/objects/contacts.cfg define contact{ contact_name test1 use generic-contact alias email1 email test1@163.com } define contact{ contact_name test2 use generic-contact alias email2 email test2@163.com } define contactgroup{ contactgroup_name common alias common members test1,test2 }说明:contact.cfg 里面既可以定义user也可以定义group,先定义两个user test1和test2,然后把这两个user加入到common组里面。发邮件时就发给common组就可以了,这时test1@163.com和test2@163.com都会收到邮件。
然后在需要告警的服务里加上contactgroup
[root@localhost ~]# vim /etc/nagios/conf.d/192.168.56.128.cfg针对check_load服务增加告警配置
define service{ use generic-service host_name 192.168.56.128 service_description check_load check_command check_nrpe!check_load max_check_attempts 5 normal_check_interval 1 contact_groups common notifications_enabled 1 notification_period 24x7 notification_options w,u,c,r }说明:notifications_enabled 1 表示是否开启提醒功能。1 为开启,0 为禁用。一般,这个选项会在主配置文件(nagios.cfg)中定义,效果相同。notification_period 24x7 表示发送提醒的时间段。如果不在定义的时间段内,无论什么问题都不会发送提醒。notification_options:w,u,c,r 表示service的状态。w 为 warning,u 为unknown,c 为critical,r 为recovery。类似的还有一个host对应的状态:d,u,r,f,n。 d 状态表示DOWN,u 为UNREACHABLE,r 状态恢复为 OK,f 为flapping,n 为不发送提醒。需要加入到 host 的定义配置里生效。
编辑完配置文件后,重启nagios服务
[root@localhost ~]# service nagios restart Running configuration check...done. Stopping nagios: done. Starting nagios: done.
相关文章推荐
- 垃圾邮件过滤器 python简单实现
- 网络监控器Nagios全攻略
- 基于Nagios网络监控平台的实现--具体事例
- Nagios 笔记 Nagios服务端+客户端 + 短信报警 + 性能显示的图形插件
- FreeBSD下解决Nagios不发报警邮件的问题
- 收到新书两本
- 5 个适合系统管理员使用的告警可视化工具
- 使用C#发送带附件的电子邮件的方法的代码示例分析
- C#实现按数据库邮件列表发送邮件的方法
- C#使用自带的email组件发送邮件的方法
- 使用C#编写简单的图形化的可发送附件的邮件客户端程序
- C#.NET采用HTML模板发送电子邮件完整实例
- 使用WordPress发送电子邮件的相关PHP函数用法解析
- php简单实现发送带附件的邮件
- C#发送内置图片html格式邮件的方法
- javascript验证邮件地址和MX记录的方法
- asp+JMAIL实现发送邮件
- asp.net mvc发送邮件实例讲解
- C++实现邮件群发的方法
- 使用Java发送带附件的附件的示例