Creating Nagios contacts and contact groups

Creating Nagios contacts and contact groups is very easy steps but most of the people struggle’s to create contacts and contact groups. Adding / Creating is easy but how you have to figure out the grouping of contacts as contact group is very crucial step.

How to Create an contact groups in Nagios Core

  Adding / Creating contact groups in Nagios there is no limit as many groups you want you can create as many contacts you want include in group you can. so now the question is about creating an appropriate groups and appropriate people in it 

Create Groups based on below metrics

  1. Service related .i.e. Web Service (Responsible people for web service monitoring / Web service owners should be in this group) like wise for each service you can create one group and include appropriate people in that
  2. Team wise groups .i.e. HelpDesk Team OR L1 Team. This team is responsible for first level escalations, Like wise based on escalation levels you can create an groups
  3. Server Owners – Who owns the device they should get the alerts when something happens in the server
  4. Customers – Customers are the heart of the business so they should get an alert when customer related services got effect / Down / Stopped

As mentioned above so many ways are there to create an group.

Note: Do not include people who are not responsible OR not related

Creating Nagios contacts and Contact Groups

Now lets see how to create an contacts and contact groups in Nagios Core. If you want modify any thing in the Nagios Core application we have to edit the configuration files there is no option to create / add any configuration from Web GUI.

Default contact configuration files are located in /usr/local/nagios/etc/objects

Note: Above path is not applicable for customized environments

Edit the config file and add below code for adding one contact

[root@ArkIT~]# vim /usr/local/nagios/etc/objects/contacts.cfg
define contact{
        contact_name            ravia
        use                     generic-contact
        alias                   Storage Administrator L3
        email                   aravikumar48@gmail.com
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
          }

define contact{
        contact_name            ramanab
        use                     generic-contact
        alias                   Linux Administrator
        email                   ramana@gmail.com
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
         }

Two contacts has been added 1. ravia 2. ramanab

Now we are going to group them as required. First Define group name and add members to it

define contactgroup {
        contactgroup_name       l2admins
        alias                   Level 2 Administrators
        members                 ravia,ramanab
        }

Now group l2admins got created and included ravia and ramanb as group members

How to enable alerts to group

we have created contacts and contact group, now we are going to add contact group to appropriate Hosts and Services

Define contact group in host to send an alerts. See below configuration, it will send an alert when host is down / Not reachable

define host{
        use                     linux-server
        host_name               arkit-webserver
        alias                   ArkIT Web Server Located in Chicago
        address                 192.168.1.15
       contact_groups       l2admins
        }

Same way if you want to add contact group to particular service then use below code, which will send an alert whenever web service is down

define service{
        use                             generic-service-storage  <<-- Template Name
        host_name                       arkit-webserver
        service_description             HTTP / Apache Service Status
        check_command                   check_http
        notifications_enabled           1
        process_perf_data               1
       contact_groups           l2admins
        }

As i explained in above adding contacts and contact group to each and every Host definition and service destination is hectic job if you have 1000 of hosts and services in monitoring, Simple and tricky way to add contact groups to each and every Host definition and service definition is define contact group directly in host template and service template. As shown below, in this way contact group is applicable for all the services which are defined using this template name.

define service{
        name                            generic-service-storage  ; <<-- Template Name
        active_checks_enabled           1                       ;
        passive_checks_enabled          1                       ;
        parallelize_check               1                       ;
        obsess_over_service             1                       ;
        check_freshness                 0                       ;
        notifications_enabled           1                       ;
        event_handler_enabled           1                       ;
        flap_detection_enabled          1                       ;
        process_perf_data               1                       ;
        retain_status_information       1                       ;
        retain_nonstatus_information    1                       ;
        is_volatile                     0                       ;
        check_period                    24x7                    ;
        max_check_attempts              3                       ;
        normal_check_interval           5                       ; 
        retry_check_interval            2                       ;
        contact_groups                 l2admins                 ;
        notification_options            c,r                     ;
        #notification_interval           60                     ;
        notification_interval           1440                    ; 
        notification_period             24x7                    ;
         register                        0                      ;
        }

Adding contact group to Host template

define host{
        name                            generic-host <<-- Host Template Name
        notifications_enabled           1            
        event_handler_enabled           1            
        flap_detection_enabled          1            
        process_perf_data               1            
        retain_status_information       1            
        retain_nonstatus_information    1            
        notification_period             24x7         
        contact_groups                  l2admins
        notification_options    d,r,s,u             
        check_command           check-host-alive     
        register                        0            
        }

Conclusion

Now you learned adding / Defining / Creating Nagios contacts and contact groups

For More Nagios related articles go here

Read More  Nagios Admin Interview Questions and Answers

SEO: creating nagios contacts

Thanks for your wonderful Support.

Stay Connected with us. Learn More and Earn More

Good Luck..!!

Ankam Ravi Kumar

Working as Linux / Storage Administrator L3. Interested in sharing the knowledge.

You may also like...

Leave a Reply