Nagios 联系人配置

Nagios 联系人配置

我正在尝试contacts.cfg在 Nagios 中创建一个,以便它在不同的事件中联系两个不同的电子邮件。一个是我们的常规电子邮件,一个是我们的 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                           [email protected]
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                           [email protected]
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.

有人能指出正确的方向吗?

答案1

您把模板和联系人定义混合在一起了(两次)。

只要您有一个包含 的对象定义register 0,就表示一个模板。同样,使用 代替namecontact_namehost_nametimeperiod_name等,视情况而定)。

你几乎肯定不想在模板中输入电子邮件地址。你也不一定需要使用模板化对象定义。

联系人的对象定义部分将向您显示联系人定义中必须包含的(或通过模板提供的)必需的指令。

有关模板的更多信息,请参阅有关对象继承的文档页面

答案2

哪个版本的 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

如果有帮助,请点赞我的回复。tia

https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html

相关内容