我试图在Nagios中创建一个contacts.cfg,这样它就可以在不同的事件中联系到两封不同的电子邮件。一个是我们的普通电子邮件,另一个是我们的gmail,它被配置成在一个事件上给我们打电话,事情出了问题。下面是我的设置
define contact {
name mainemail
service_notification_options c,u,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
register 0
email alert@xxmail.net
service_notification_period 24x7
host_notification_period 24x7
}
define contact {
name emergencyadmin
service_notification_options c,u
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
register 0
email xxx@gmail.com
service_notification_period 24x7
host_notification_period 24x7
}
define contactgroup {
contactgroup_name nagiosadmin-emergencyadmin
members mainemail,emergencyadmin
}我的错误是
Error: Unexpected token or statement in file '/usr/local/nagios/etc/objects/contacts.cfg' on line 7.
Error processing object config files!
***> One or more problems was encountered while processing the config files...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.有人能指出正确的方向吗?
发布于 2015-12-07 23:52:58
您将模板和联系人定义混合在一起(两次)。
每当您有一个包含register 0的对象定义时,它就指示一个模板。使用name代替contact_name (或host_name、timeperiod_name等,视情况而定)。
您几乎肯定不想将电子邮件地址放在模板中。您也不一定需要使用模板对象定义。
联系人的对象定义部分将向您展示必须在联系人定义中(或通过模板提供)所需的指令。
有关模板的更多信息,请参见关于对象继承的docs页面。
发布于 2015-12-07 23:27:18
哪种版本的Nagios?Nagios Core 3&4要求联系人定义如下:
define contact {
contact_name contact_name
host_notifications_enabled [0/1]
service_notifications_enabled [0/1]
host_notification_period timeperiod_name
service_notification_period timeperiod_name
host_notification_options [d,u,r,f,s,n]
service_notification_options [w,u,c,r,f,s,n]
host_notification_commands command_name
service_notification_commands command_name
}在您的示例中,我没有看到contact_name host_notifications_enabled或service_notifications_enabled。
如果这有帮助,请支持我的回答。提亚
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html
https://serverfault.com/questions/741415
复制相似问题