Using PEM with Nagios

The PEM server can send a passive alert result to Nagios network-alerting software when an alert is triggered. To instruct the PEM server to notify Nagios of a triggered alert, you must:

  • Enable Nagios notification for each alert that will trigger a notification from the PEM server to Nagios. Please note that PEM alerting must be configured before you create the host.cfg file, the services.cfg file, or configure Nagios.
  • Configure Nagios-related behaviors of the PEM server.
  • Create the host.cfg and services.cfg configuration files.
  • If necessary, modify the Nagios configuration file and restart the server.

Detailed information about each configuration step is listed below.

After configuring the server to enable Nagios alerting, any triggered alerts will send a passive check result to the Nagios service. The syntax of a passive alert is:

[timestamp] PROCESS_SERVICE_CHECK_RESULT; host_name ; service_name ; service_status ;

Where:

  • timestamp is the date and time that the alert was triggered.
  • host_name is the name of the server or agent.
  • service_name is the name of the alert.
  • service_status is the numeric service status value:
    • 0 if the service status is OK
    • 1 if the service status is WARNING
    • 2 if the service status is CRITICAL
    • 3 if the service status is UNKNOWN

The PEM server uses the following rules to evaluate the service status:

  • If the PEM alert level is CLEARED, the warning message will read OK
  • If the PEM alert level is LOW, the warning message will read WARNING
  • If the is_nagios_medium_alert_as_critical flag (specified in the PEM server configuration dialog) is set to FALSE and the alert level is MEDIUM, the warning message will read WARNING
  • If the is_nagios_medium_alert_as_critical flag (specified in the PEM server configuration dialog) is set to TRUE and the alert level is MEDIUM, the warning message will read CRITICAL
  • If the PEM alert level is HIGH, the warning message will read CRITICAL

Enabling Nagios Notification for an Alert

The PEM server maintains a unique set of notification properties for each enabled alert. Use the Notification tab of the *Manage Alerts* tab to specify that (when triggered), a given alert will send an alert notice to Nagios. To modify the notification properties of an alert, right-click on the name of the object monitored by the alert, and select Manage Alerts… from the Management menu. When the Manage Alerts tab opens, locate the alert, and then click the edit button to the left of the alert name in the Alerts list. When the Manage Alerts tab opens, select the Notification tab.

_images/nagios_alert_notification.png

To enable Nagios notification, move the slider next to Submit passive service check result to Nagios to Yes; before exiting the Manage Alerts tab, click the save icon to preserve your changes.

Creating the hosts.cfg and services.cfg File

The templates.cfg file (by default, located in /usr/local/nagios/etc/objects) specifies the properties of a generic-host and generic-service. The properties specify the parameters used in the hosts.cfg and services.cfg files.

In most cases (when PEM is installed in a default configuration), you will not be required to modify the templates.cfg file before creating the hosts.cfg and services.cfg files. If necessary, you can modify the templates.cfg file to specify alternate values for parameters or to create new templates.

Before modifying the Nagios configuration file, use the following command to create a hosts.cfg file that contains information about the PEM hosts that reside on the local system:

./psql -U postgres -p 5433 -d pem -A -t -c “select pem.create_nagios_host_config(‘generic-host’)” > /usr/local/nagios/etc/objects/hosts.cfg

Then, use the following command to create a services.cfg file that contains information about the PEM services that reside on the local system:

./psql -U postgres -p 5433 -d pem -A -t -c “select pem.create_nagios_service_config(‘generic-service’)” > /usr/local/nagios/etc/objects/services.cfg

If you wish to use a custom template.cfg file entry, specify the entry name in place of generic-host or generic-service in the above commands.

Modifying the Nagios Configuration File

After creating the host.cfg and services.cfg files, you must specify their location in the Nagios configuration file (by default, /usr/local/nagios/etc/nagios.cfg). Modify the configuration file, adding entries that specify the location of the files:

cfg_file=/usr/local/etc/objects/hosts.cfg cfg_file=/usr/local/etc/objects/services.cfg

You can use the following command to confirm that Nagios is properly configured:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

After confirming that Nagios is configured correctly, restart the Nagios service:

/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg