我有以下服务configuration捕获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 应该是一个命名pipe道。 在我的情况下,这只是一个普通的旧文件:
从我们的日志档案中,我可以看到被动检查在过去的某个时间点被处理,但是现在他们不再工作了。
我正在查看configuration再次查找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提到的其他任务,创build了命名pipe道。