Nagios通知定义

我试图监视一个Web服务器的方式,我想通过httpsearch页面上的特定string。 该命令在command.cfg中定义如下

# 'check_http-mysite command definition' define command { command_name check_http-mysite command_line /usr/lib/nagios/plugins/check_http -H mysite.example.com -s "Some text" } # 'notify-host-by-sms' command definition define command { command_name notify-host-by-sms command_line /usr/bin/send_sms $CONTACTPAGER$ "Nagios - $NOTIFICATIONTYPE$ :Host$HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)" } # 'notify-service-by-sms' command definition define command { command_name notify-service-by-sms command_line /usr/bin/send_sms $CONTACTPAGER$ "Nagios - $NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)" } 

现在,如果nagios在主页mysite.example.com上找不到“Some text”,那么nagios应该通过Clickatell HTTP API的短信来通知一个联系人,我有一个脚本来testing它,发现它工作正常。

每当我改变命令定义来search一个不在页面上的string,然后重新启动nagios时,我可以在web界面上看到没有find该string。 我不明白的是为什么不是通知发送,虽然我已经定义了主机,主机组,联系人,联系人组和服务等等。 我错过了什么,这些是我的定义,在通过CGI的Web访问中,我可以看到,我已经定义和启用了通知,但在硬状态更改期间,我没有收到电子邮件和短信通知。

host.cfg

 define host { use generic-host host_name HAL alias IBM-1 address xxx.xxx.xxx.xxx check_command check_http-mysite } 

hostgroups_nagios2.cfg

 # my website define hostgroup{ hostgroup_name my-servers alias All My Servers members HAL } 

contacts_nagios2.cfg

 define contact { contact_name colin alias Colin Y service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r,f,s host_notification_options d,u,r,f,s service_notification_commands notify-service-by-email,notify-service-by-sms host_notification_commands notify-host-by-email,notify-host-by-sms email [email protected] pager +254xxxxxxxxx } define contactgroup{ contactgroup_name site_admin alias Site Administrator members colin } 

services_nagios2.cfg

 # check for particular string in page via http define service { hostgroup_name my-servers service_description STRING CHECK check_command check_http-mysite use generic-service notification_interval 0 ; set > 0 if you want to be renotified contacts colin contact_groups site_admin } 

有人可以告诉我哪里错了吗?

这是通用主机和通用服务定义

仿制service_nagios2.cfg

 # generic service template definition define service{ name generic-service ; The 'name' of this service template 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 (disabling this can lead to major performance problems) obsess_over_service 1 ; 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 failure_prediction_enabled 1 ; Failure prediction 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 notification_interval 0 ; Only send notifications on status change by default. is_volatile 0 check_period 24x7 normal_check_interval 5 retry_check_interval 1 max_check_attempts 4 notification_period 24x7 notification_options w,u,c,r contact_groups site_admin register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! } 

仿制host_nagios2.cfg

 define host{ name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host event handler is enabled flap_detection_enabled 1 ; Flap detection is enabled failure_prediction_enabled 1 ; Failure prediction 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 max_check_attempts 10 notification_interval 0 notification_period 24x7 notification_options d,u,r contact_groups site_admin register 1 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! } 

我想通了,实际上configuration是好的,问题是nagios执行SMS脚本作为用户'nagios',它没有权限写入/ tmp /中的日志文件。 但是在我通过短信设置nagios通知阅读的任何博客中都没有解释这一点。 我有点不得不自己找出来,差点让我的脑袋爆炸了。