Linux – Possible to override contacts for just one Nagios host group

centoslinuxnagiosUbuntu

The contact for all my linux hosts is the admins Nagios contact_group. But for this one Linux host would I like that the contact_group called sandradebug also gets notified.

The problem is, that when I add contact_groups sandradebug it is still only admins that gets the notification and not also sandradebug.

Question

How can I include sandradebug for this one host, so notifications are also sent there?

Host template

define host {
  name                          linux-host
  use                           generic-host
  check_command                 check-host-alive
  notification_interval         4320
  notification_options          d,u,r
  contact_groups                admins
  register                      0
}

Host definition

define host {
  use                     linux-host
  host_name               example
  alias                   example
  address                 10.10.10.10
  hostgroups              default-linux-services
  contact_groups          sandradebug
}

Best Answer

The problem is, that when I add contact_groups sandradebug it is still only admins that gets the notification and not also sandradebug.

Have you restarted the Nagios? Your above configuration will override the template values and only sandradebug group will receive these alerts.

How can I include sandradebug for this one host, so notifications are also sent there?

Object Inheritance is what you are looking for:

define host {
    use                     linux-host
    host_name               example
    alias                   example
    address                 10.10.10.10
    hostgroups              default-linux-services
    contact_groups          +sandradebug
}

Using the + sign, the host definition uses the data in the template and adds the sandradebug to the alerts.