1

I am trying to create a contacts.cfg in Nagios so that it will contact two different email at different events. One is our regular email and one is our gmail which is configured to call us on an event something went down. Below are my settings

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
}

and my errors are

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.

Can anyone point towards right direction?

2 Answers 2

2

You have mixed a template and a contact definition together (twice).

Whenever you have an object definition that includes register 0, that indicates a template. Same for use of name instead of contact_name (or host_name, timeperiod_name, etc., as appropriate).

You almost certainly don't want to put the email addresses in the templates. And you don't necessarily need to use templated object definitions, either.

The object definitions section for contacts will show you the required directives that must be in the contact definition (or supplied via a template).

For more information on templates, see the docs page on Object Inheritance.

0

Which version of Nagios? Nagios Core 3 & 4 require the following for a contact definition:

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
}

I don't see contact_name host_notifications_enabled or service_notifications_enabled in your example.

If this helps, please upvote my response. tia

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .