我有一个问题,我的nofication命令不扩展$ CONTACTEMAIL $macros
(使用debian软件包在Debian上安装版本3.2.1)
me@hostname:/etc/nagiosql# dpkg -l | grep nagios ii nagios-images 0.7 Collection of images and icons for the nagios system ii nagios-nrpe-plugin 2.12-4 Nagios Remote Plugin Executor Plugin ii nagios-plugins 1.4.15-3squeeze1 Plugins for the nagios network monitoring and management system ii nagios-plugins-basic 1.4.15-3squeeze1 Plugins for the nagios network monitoring and management system ii nagios-plugins-standard 1.4.15-3squeeze1 Plugins for the nagios network monitoring and management system ii nagios3 3.2.1-2 A host/service/network monitoring and management system ii nagios3-cgi 3.2.1-2 cgi files for nagios3 ii nagios3-common 3.2.1-2 support files for nagios3 ii nagios3-core 3.2.1-2 A host/service/network monitoring and management system core files
我有这个在我的commands.cfg
define command { command_name notify_by_email command_line /usr/bin/printf "%b" "Notification:\t$NOTIFICATIONTYPE$\n\nOccurred:\t$DATETIME$\nHostname:\t$HOSTALIAS$ ($HOSTADDRESS$)\nService:\t$SERVICEDESC$\nState:\t\t$SERVICESTATE$\nDetails:\n\ n$OUTPUT$" | /usr/bin/mail -s "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ -- $SERVICESTATE$" $CONTACTEMAIL$ register 1 }
并在contacts.cfg中
define contact { contact_name navaho contactgroups pagers host_notifications_enabled 1 service_notifications_enabled 1 host_notification_period 24x7 service_notification_period 24x7 host_notification_options d,u,r,f,s service_notification_options w,u,c,r,s,n host_notification_commands notify_by_email service_notification_commands notify_by_email email [email protected] register 1 }
在我的服务configuration文件中
define service { host_name servicehost.mydomain.com hostgroup_name null service_description SE: display_name SE: check_command check_se max_check_attempts 5 check_interval 5 retry_interval 5 active_checks_enabled 1 check_period 24x7 event_handler notify_by_email notification_interval 5 notification_period 24x7 notification_options w,u,r,c,s notifications_enabled 1 contacts navaho contact_groups pagers register 1 }
有了这些configuration,我希望nagios发送通知到电子邮件地址[email protected],如果我closuresmyservicehost上的SE:服务。 它不。
Aug 1 13:56:12 myhostname postfix/cleanup[25382]: 2DC5F28054: message-id=<[email protected]> Aug 1 13:56:12 myhostname postfix/qmgr[22452]: 2DC5F28054: from=<[email protected]>, size=470, nrcpt=1 (queue active) Aug 1 13:56:12 myhostname postfix/local[25384]: 2DC5F28054: to=<[email protected]>, orig_to=<$>, relay=local, delay=0.07, delays=0.05/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: "$") Aug 1 13:56:12 myhostname postfix/cleanup[25382]: 3B96B28055: message-id=<[email protected]>
请注意[email protected],orig_to =
当我在commands.cfg中修改命令以将其硬编码到我的实际电子邮件时,它发送完美
/usr/bin/printf "%b" "Notification:\t$NOTIFICATIONTYPE$\n\nOccurred:\t$DATETIME$\nHostname:\t$HOSTALIAS$ ($HOSTADDRESS$)\nService:\t$SERVICEDESC$\nState:\t\t$SERVICESTATE$\nDetails:\n\ n$OUTPUT$" | /usr/bin/mail -s "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ -- $SERVICESTATE$" [email protected]
我可能会错过什么使nagios不扩展$ CONTACTEMAIL $macros?
编辑:通过量子张贴在下面的build议后,我打开了debugging,并使用一个按需macros来看看nagios正在做什么。 虽然我还不能解释为什么,但nagios似乎没有扩大macros观,因为它是裸露的。 我将$ CONTACTEMAIL $更改为“$ CONTACTEMAIL”,并开始工作。
nagios.log $CONTACTEMAIL:navaho$来查看是否有效 问题是service_notification_options中的'n':
http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html
service_notification_options:如果您指定n(无)作为选项,联系人将不会收到任何types的服务通知。
您的contacts.cfg中有错误。
从列表中删除n service_notification_options n代表none …
喜欢这个:
define contact { contact_name navaho contactgroups pagers host_notifications_enabled 1 service_notifications_enabled 1 host_notification_period 24x7 service_notification_period 24x7 host_notification_options d,u,r,f,s service_notification_options w,u,c,r,s host_notification_commands notify_by_email service_notification_commands notify_by_email email [email protected] register 1 }
在Quanta的build议下面张贴我打开debugging,然后使用随需应变的macros来看看实际上在做什么。 虽然我还不能解释为什么,但nagios似乎没有扩大macros观,因为它是裸露的。 我将$ CONTACTEMAIL $更改为“$ CONTACTEMAIL $”,并开始工作。 奇怪的是,双引号没有工作。
当我更多地使用它时,看起来$ OUTPUT $有未转义的html,导致了这个问题。
尝试将$ CONTACTEMAIL $放在command.cfg中的command_line中
$ CONTACTEMAIL $string中是否包含任何不可打印的字符,因此不能匹配任何内容?