nagios配置解释

简介:
nagios配置解释
notifications_enabled [0/1] ; 是否开启提醒功能。"1" 为开启,"0" 为禁用。一般,这个选项会在主配置文件 (nagios.cfg) 中定义,效果相同。
stalking_options [o,d,u] ; 持续状态检测参数,o = 持续的 UP 状态 , d = 持续的 DOWN 状态 , u = 持续的 UNREACHABLE 状态
}

服务监控的配置

define service {
host_name host_name
service_description service_description
servicegroups servicegroup_names
is_volatile [0/1]
check_command command_name
max_check_attempts
normal_check_interval
retry_check_interval
active_checks_enabled [0/1]
passive_checks_enabled [0/1]
check_period timeperiod_name
parallelize_check [0/1]
obsess_over_service [0/1]
check_freshness [0/1]
freshness_threshold
event_handler command_name
event_handler_enabled [0/1]
low_flap_threshold
high_flap_threshold
flap_detection_enabled [0/1]
process_perf_data [0/1]
retain_status_information [0/1]
retain_nonstatus_information [0/1]
notification_interval
notification_period timeperiod_name n
otification_options [w,u,c,r,f]
notifications_enabled [0/1]
contact_groups contact_groups
stalking_options [o,w,u,c]
}

服务监控的配置和主机监控的配置较为相似,就不一一说明了。

间隔时间的计算方法为:
normal_check_interval x interval_length 秒
retry_check_interval x interval_length 秒
notification_interval x interval_length 秒

主机监控配置的例子

define host {
host_name web1
alias web1
address 192.168.0.101
contact_groups admins
check_command check-host-alive
max_check_attempts 5
notification_interval 0
notification_period 24x7
notification_options d,u,r
}

对主机 web1 进行 24x7 的监控,默认会每 10 秒检查一次状态,累计五次失败就发送提醒,并且不再重复发送提醒。

服务监控配置的例子

define service {
host_name web1
service_description check_http
check_period 24x7
max_check_attempts 3
normal_check_interval 30
contact_groups admins
retry_check_interval 15
notification_interval 3600
notification_period 24x7
notification_options w,u,c,r
check_command check_http
}

配置解释: 24x7 监控 web1 主机上的 HTTP 服务,检查间隔为 30 秒, 检查失败后每 15 秒再进行一次检查,累计三次失败就认定是故障并发送提醒。
联系人组是 admins 。提醒后恢复到 30 秒一次的 normal_check_interval 检查。如果服务仍然没有被恢复,每个小时发送一次提醒。

如果要检测其他服务,例如,要检查 ssh 服务是否开启,更改如下两行:
service_description check_ssh
check_command check_ssh

为方便管理,对配置文件的分布做了如下修改:
nagios.cfg 中增加了:
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/services

在 hosts 目录中,为不同类型的主机创建了配置文件,如: app.cfg cache.cfg mysql.cfg web.cfg
并创建了 hostgroup.cfg 文件对主机进行分组,如:

define hostgroup {
hostgroup_name app-hosts
alias APP Hosts
members app1,app2
}

在 services 目录中创建了各种服务的配置文件,如: disk.cfg http.cfg load.cfg mysql.cfg
并创建了 servicegroup.cfg 文件对服务进行分组,如:

define servicegroup {
servicegroup_name disk
alias DISK
members cache1,check_disk,cache2,check_disk
}

本文转自 holy2009 51CTO博客,原文链接:http://blog.51cto.com/holy2010/329232
相关文章
|
Kubernetes Shell Go
3天玩转shell--12.实战编写nginx日志统计脚本【终结篇】
本节课是shell教程系列的最后一篇文章,希望这12篇文章对shell的学习者有帮助。往后有空会发表一些关于golang编程的实战系列文章、或者是k8s相关的文章。
464 0
3天玩转shell--12.实战编写nginx日志统计脚本【终结篇】
|
缓存 前端开发 Unix
nginx.conf配置文件各项详解(建议收藏查阅)(上)
nginx.conf配置文件各项详解(建议收藏查阅)
235 0
nginx.conf配置文件各项详解(建议收藏查阅)(上)
|
Web App开发 缓存 负载均衡
nginx.conf配置文件各项详解(建议收藏查阅)(中)
nginx.conf配置文件各项详解(建议收藏查阅)
396 0
|
应用服务中间件 Shell Apache
nginx.conf配置文件各项详解(建议收藏查阅)(下)
nginx.conf配置文件各项详解(建议收藏查阅)
181 0
|
监控 Unix Linux
Zabbix zabbix_agentd指令(学习笔记二十七)
zabbix_agentd概念 zabbix_agentd非常非常重要,把zabbix_agentd安装到被监控服务器上,zabbix_server便可以和zabbix_agentd通信来获取数据。
1214 0
|
监控 Linux 应用服务中间件