Nagios NRDP – Setting Up The Test Environment

Nagios NRDP – Setting Up The Test Environment

This following pages of this article explain how to set up the test environment used for this series of wiki pages. After installing and testing NRDP the next step is to set up a simple test environment where the remote Nagios server NAG-REMOTE and its services are configured for passive monitoring on the central Nagios server NAG-CENTRAL.

For the purposes of this article the hostname will be changed from localhost to NAG-REMOTE on the remote Nagios server NAG-REMOTE. This is being changed as otherwise the $HOSTNAME$ variable sent as part of the check results by the send_nrdp.py client will be localhost.

The following sections of this article will consist of the following:

  • Remote Server – Changing the hostname
  • Remote Server – Changing the initial state for hosts and services
  • Central Server – Configuring a passive host template
  • Central Server – Configuring a passive service template

Remote Server – Changing the hostname

The first step is to rename the Remote Nagios server’s hostname in the configuration file localhost.cfg to ensure that send_nrdp.py sends the correct hostname to the central Nagios server.

To change the hostname perform the following on the remote Nagios server NAG-REMOTE:

  • SSH to NAG-REMOTE as a normal user
  • Switch to root in by executing the command below:
su
  • Edit the localhost.cfg configuration file /usr/local/nagios/etc/objects/localhost.cfg by executing the command below:
vi /usr/local/nagios/etc/objects/localhost.cfg
  • Change the host_name value from localhost to NAG-REMOTE as shown below:
define host {
   use        linux-server
   host_name  NAG-REMOTE
   alias      NAG-Remote
   address    127.0.0.1
}
  • Change the host_name entries for the linux-servers hostgroup definition and all services by executing the following in vi:
:%s/localhost/NAG-REMOTE/
  • Save and exit the file
  • Restart the nagios service by executing the command below:
systemctl restart nagios

Remote Server – Changing the initial state for hosts and services

The next step is to change the initial state settings for hosts and services on the remote Nagios server NAG-REMOTE.  Changing these to Unreachable for Hosts and Unknown for Services will ensure that the first check the remote server does triggers the send_nrdp global event commands and updates the central Nagios server.  In the default configuration, the remote server will not send check results for the initial checks to the central server which means they will show as PENDING until a state change occurs on the remote Nagios server.

This could probably be achieved by setting the initial state on the central Nagios server so that they are presumed to be OK but I prefer for them to turn to the correct state when first checked on the remote Nagios server.

To change the initial states for the hosts and services on the remote Nagios server perform the following:

  • Edit the templates.cfg configuration file /usr/local/nagios/etc/objects/templates.cfg by executing the command below:
vi /usr/local/nagios/etc/objects/templates.cfg
  • Find the generic-host definition and add the line initial_state shown below to set hosts initial state to Unreacheable:
define host {
   name                          generic-host 
   notifications_enabled         1
   event_handler_enabled         1
   flap_detection_enabled        1 
   process_perf_data             1
   retain_status_information     0
   retain_nonstatus_information  1
   notification_period           24x7
   initial_state                 u
   register                      0
}
  • Find the generic-service definition and add the initial_state line shown below to set services initial state to Unknown:
define service {
   name                           generic-service
   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      0
   retain_nonstatus_information   1
   is_volatile                    0
   check_period                   24x7
   max_check_attempts             3
   check_interval                 10
   retry_interval                 2
   contact_groups                 admins
   notification_options           w,u,c,r
   notification_interval          60
   notification_period            24x7
   initial_state                  u
   register                       0
}
  • Save and exit the file
  • Restart the nagios service by executing the command below:
systemctl restart nagios

Central Server – Configuring a passive host template

The next step is to create a passive host template on the central Nagios server NAG-CENTRAL which can then be used to create the host definition for NAG-REMOTE and receive the host check results via NRDP.

To configure a passive host template, perform the following on the central Nagios server NAG-CENTRAL:

  • SSH to NAG-CENTRAL as a normal user
  • Switch to root in by executing the command below:
su -i
  • Edit the template.cfg configuration file /usr/local/nagios/etc/objects/template.cfg by executing the command below:
vi /usr/local/nagios/etc/objects/template.cfg
  • Go to the end of the file and add the following text to configure a passive host definition template definition:
define host {
 name                              passive_host
 notifications_enabled             1
 event_handler_enabled             1
 retain_status_information         0
 retain_nonstatus_information      1
 flap_detection_enabled            1
 process_perf_data                 1
 active_checks_enabled             0
 passive_checks_enabled            1
 notification_period               24x7
 check_period                      24x7
 notification_interval             120
 notification_options              d,u,r
 contact_groups                    admins
 max_check_attempts                10
 check_interval                    5
 retry_interval                    1
 register                          0
}
  • Save and exit the file

Central Server – Configuring a passive service template

The next step is to create a passive service template on the central Nagios server NAG-CENTRAL which can then be used to create the service definitions for NAG-REMOTE and receive the service check results via NRDP.

To configure a passive service template, perform the following on the central Nagios server NAG-CENTRAL:

  • Edit the template.cfg configuration file /usr/local/nagios/etc/objects/template.cfg by executing the command below:
vi /usr/local/nagios/etc/objects/template.cfg
  • Go to the end of the file and add the following text to configure a passive service definition template definition:
define service {
 name                      passive_service_check
 register                  0
 max_check_attempts        1
 check_interval            1
 retry_interval            1
 active_checks_enabled     0
 passive_checks_enabled    1
 notifications_enabled     1
 check_freshness           1
 freshness_threshold       93600
 check_period              24x7
}
  • Save and exit the file

Previous Page                                                                                                                                          Next Page

Leave a Reply

Your email address will not be published.