我有以下服务配置来捕获 SNMP 陷阱:
define service {
name SNMP_TRAP
service_description SNMP_TRAP
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized
process_perf_data 0
obsess_over_service 0 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
check_command check-host-alive ; This will be used to reset the service to "OK"
is_volatile 1
check_period 24x7
max_check_attempts 1
normal_check_interval 1
retry_check_interval 1
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
register 0
}
define service {
use SNMP_TRAP
service_description gigabitethernet16
hostgroup_name cisco
check_interval 120
}
我在cisco
组中有几个设备,例如:
define host {
use base-host
host_name cisco-sg300-28-4
alias CISCO-SG300-28 (VT-Registratur)
display_name Switch VT-Registratur
address 10.0.1.109
hostgroups switches,cisco,cisco28
}
该服务在 Web 界面上显示正常:
但是,收到的服务检查根本没有处理。我的/var/lib/nagios3/rw/nagios.cmd
文件收集了结果,但文件从未被清除,结果也不会出现在 Nagios 中。nagios.cmd
例如包含:
[1437659629] PROCESS_SERVICE_CHECK_RESULT;cisco-sg300-28-4;gigabitethernet16;2;gigabitethernet16 linkDown
accept_passive_service_checks
已在 中启用nagios.cfg
。
经过进一步检查,我nagios.cmd
意识到应该是一个命名管道。在我的例子中,它只是一个普通的旧文件:
从我们的日志存档中,我可以看到被动检查在过去的某个时间点被处理,但现在它们不再起作用了。
答案1
我再次查看配置以查找更多详细信息nagios.cmd
并发现了以下内容:
# EXTERNAL COMMAND FILE
# This is the file that Nagios checks for external command requests.
# It is also where the command CGI will write commands that are submitted
# by users, so it must be writeable by the user that the web server
# is running as (usually 'nobody'). Permissions should be set at the
# directory level instead of on the file, as the file is deleted every
# time its contents are processed.
# Debian Users: In case you didn't read README.Debian yet, _NOW_ is the
# time to do it.
command_file=/var/lib/nagios3/rw/nagios.cmd
因此,这给了我一个想法去查看README.Debian
,它位于/usr/share/doc/nagios3-common/README.Debian
并包含以下指令:
- activate external command checks in the nagios configuration. this
can be done by setting check_external_commands=1 in the file
/etc/nagios3/nagios.cfg.
虽然我确信这个指令已启用,但我仔细检查了一下,发现它实际上不是已启用。
启用它(并执行中提到的其他任务)后README
,命名管道就创建了。