我想使用 SNMP 陷阱,因此我需要执行外部 nagios 命令。
我已经检查过配置:
check_external_commands=1
command_check_interval=-1
命令文件可以访问。
当我向 nagios 发送外部命令时,该命令显示在日志中,但似乎没有执行。因此,我尝试在 Web 界面中设置被动检查的结果(提交被动检查结果...)。日志显示:
[1484062350] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;server11;RAID-Array;1;Testing|
什么都没发生。
服务定义:
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 netops-24x7 ; Modify this to match your Nagios contact group definitions
register 0
}
define service {
use SNMP_TRAP
host_name server11
service_description RAID-Array
check_interval 120 ; Don't clear for 2 hours
}
答案1
您可以检查包含 nagios 必须执行的所有外部命令的文件:
tail -f /usr/local/nagios/var/rw/nagios.cmd
此外,如果您使用以下语法直接在此文件中写入,则可以在本地测试您的命令:
echo [timestamp] PROCESS_SERVICE_CHECK_RESULT;server11;RAID-Array;1;Testing >> /usr/local/nagios/var/rw/nagios.cmd
确定:
- 您发送给 nagios 的时间戳与您的服务器的日期相同。
- 您的主人的姓名,
- 您的服务名称,该服务在您的主机中声明