IP | 主机名 | 节点类型 |
---|---|---|
192.168.100.41 | z | 主节点 |
192.168.100.43 | client | 从节点 |
实验环境已关闭防火墙和Selinux
往期回顾:
(1)安装nagios、nagios-plugins、nrpe
(2)nagios自定义简单监控脚本远程监控服务器
(3)nagios的主从切换高可用部署和配置邮件告警
此节内容
序号 | 内容 |
---|---|
1 | 设置邮件告警次数只通知1次 |
2 | 添加对监控项的告警 |
一、设置告警次数只通知一次
编辑监控项
[root@nagios-client ~]# vim /usr/local/nagios/etc/objects/192.168.100.43.cfg
define service{
use local-service
host_name client
service_description port_nginx
check_command check_nrpe!port_nginx
max_check_attempts 5
normal_check_interval 0 //定义为0,报警只发送一次,不重发.
max_check_attempts 1 //定义为1,检测到问题后立即报警,不重试.
}
[root@nagios-client ~]# systemctl restart nagios //重启nagios生效
二、给上次自定义添加的监控项设置告警
添加contact_groups即可
define host{
use linux-server
host_name client
alias client
address 192.168.100.43
contact_groups admins //设置组
}
define hostgroup {
hostgroup_name test
alias test
members localhost,client
}
define service{
use local-service
host_name client
service_description port_nginx
check_command check_nrpe!port_nginx
max_check_attempts 5
normal_check_interval 1
contact_groups admins //设置组
}
define service{
use local-service
host_name client
service_description port_mysql
check_command check_nrpe!port_mysql
max_check_attempts 5
normal_check_interval 1
contact_groups admins //设置组
}
define service{
use local-service
host_name client
service_description port_httpd
check_command check_nrpe!port_httpd
max_check_attempts 5
normal_check_interval 1
contact_groups admins //设置组
}
三、学习后期运维
可以到此网址上学习nagios的后期运维: https://blog.51cto.com/xtony/978758