Inheriting from multiple templates - notification probems

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mitchsmith
Posts: 33
Joined: Mon Apr 04, 2011 7:26 am

Inheriting from multiple templates - notification probems

Post by mitchsmith »

Due to the scale of my moitoring, I implement and inherit from a 3 templates for every service check (difering depending on the location, check type, and the template for a particular service check.
Below is an example:

Code: Select all

define service{
        name                                  chk-bkgnd-jobs
        service_description             check-background-jobs
        check_command                   check_nrpe_arg!run_check!check_background_jobs
        check_interval                     30
        retry_interval                       5
        contacts                              alerts-critical
        register                               0
        }

Code: Select all

# Application Service Definition - Template
define service{
        name                            App-service
        use                             distributed-service
        notifications_enabled           1                       ; Service notifications are DISABLED
     #   notification_options            w,u,c,r                 ; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           30                   ; Re-notify about service problems every hour
#        notification_period             24x7
        register                        0
        }

Code: Select all

define service{
        name                            location-check-service
        use                             BASE-location-service
        normal_check_interval           5
        retry_check_interval            5
        check_period                    locationTime
        notification_period             locationTime
        notification_options            c,r
        contacts                        OperationsLocation
#       contact_groups                  Location-Live,Location-chk
        register                        0
}
Then the actual service check is executed as:

Code: Select all

define service{
      use                             App-service, location-check-service,chk-bkgnd-jobs
      host_name                  HOST01
      }

The App-Serivice definition, ensures that the the checks are reported to the central nagios server.

The location-check-serivce specifies the location, and type of check (front end, back end, database)

The chk-bkgnd-jobs is the actual service check definition.

The Problem
Notification contacts are specified in location-check-service, and for the specific service check definition.
The notifications are only sent to the contacts, specified in the location-check-service

Can anybody help me here?

Thanks,

Mitchell
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Inheriting from multiple templates - notification probem

Post by jsmurphy »

Easy problem :), you cannot inherit multiple templates where they contain the same values... that is to say Nagios will only accept the last read directive, it will not (by default) attempt to reconcile or combine the two.

I.e. Lets assume it reads chk-bkgnd-jobs first, it will assign contacts to alerts-critical. Assume it then reads location-check-service it will re-assign the value of contacts to OperationsLocation and thus you will only get alerts to that contact.

Now you could change your location-check-service to as follows:

define service{
name location-check-service
use BASE-location-service
normal_check_interval 5
retry_check_interval 5
check_period locationTime
notification_period locationTime
notification_options c,r
contacts +OperationsLocation
# contact_groups Location-Live,Location-chk
register 0
}

With the plus symbol it will append to contacts rather than re-assign it. I would consider trying to simplify your approach though as you are setting yourself up for a configuration nightmare later on.
mitchsmith
Posts: 33
Joined: Mon Apr 04, 2011 7:26 am

Re: Inheriting from multiple templates - notification probem

Post by mitchsmith »

Thanks,

The append should solve the issue.

I know this approach seems complicated, and admit its not the best approach. But due to the distribution of the applications monitored, for different locations, some of which are the same checks, for different locations, this is the most effective template implementation, as it reduces the duplication of writting each service check, with differing location/project parameters.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Inheriting from multiple templates - notification probem

Post by jsmurphy »

Glad I could help, as long as your design works for you that's all that matters :D
Locked