Setup Nagios Core Integration
  • 07 Jun 2022
  • 2 Minutes to read
  • Dark
    Light
  • PDF

Setup Nagios Core Integration

  • Dark
    Light
  • PDF

After you generate your scripts in SysAid, you must configure Nagios Core to run those scripts to automatically generate the SRs you want and to import the hosts you are monitoring with Nagios to SysAid Asset Management.

Automatically create SRs for Nagios events and alerts

The first two of the three scripts you generated allow Nagios to automatically create SRs in SysAid for events and alerts relating to hosts and services you are monitoring. The following procedure enables Nagios to run those scripts and communicate the information to SysAid. You can repeat this process to configure different host groups or service groups to run different scripts.

Preparatory Steps

Before modifying any of your Nagios files, be sure to take the following steps.

  1. Backup the following files:
    • contacts.cfg
    • commands.cfg
    • nagios.cfg
  2. Restart Nagios to validate the current configuration with the following command: 
    ActionScript
    service nagios restart
  3. Transfer the "sysaid_host_notification.bash" and the "sysaid_service_notification.bash" script files that you generated in SysAid to the nagios/libexec/eventhandlers folder.
  4. Change the access permissions on the scripts to allow their execution, using chmod: 
    ActionScript
    chmod +x sysaid_host_notification.bash sysaid_service_notification.bash
    

Update the Nagios configuration files

  1. Locate the nagios.cfg file and update the enable_environment_macros parameter to '1':
    ActionScript
    enable_environment_macros=1
  2. Update the Command configuration file to run the scripts:
    1. Locate the commands.cfg file in the "/usr/local/nagios/etc/objects" directory.
    2. Add a command for each of the two scripts that includes a command name you select and command line that provides the full path for the script 
    3. Sample command definitions
      ActionScript
      define command{
      command_name notify-sysaid-host-event
      command_line /usr/local/nagios/libexec/eventhandlers/sysaid_host_notification.bash
      }
      define command{
      command_name notify-sysaid-service-event
      command_line /usr/local/nagios/libexec/eventhandlers/sysaid_service_notification.bash
      }
  3. Update the Contacts configuration file to run the script:
    1. Locate the contacts.cfg file in the "/usr/local/nagios/etc/objects" directory.
    2. Define a new contact to receive the commands you defined in the commands.cfg file.
    3. Specify the contact name and alias.
    4. Specify if the contact should receive both host and service notifications.
    5. Specify the time-frame for receiving notifications.
    6. Specify the type of host and service notifications that should be sent to the contact (see the Notification Options table below for more information).
    7. Specify the commands you defined in the commands.cfg file.
  4.  Enable the new contact in Nagios by adding it to the hosts and services you want to receive notifications for. This is usually done by adding the contact to a contact group as in the following sample command in the contacts.cfg file:
    ActionScript
    define contactgroup{
    contactgroup_name admins
    alias Nagios Administrators
    members nagiosadmin,sysaid
    }
  5. Restart Nagios with the following command:
    ActionScript
    service nagios restart

Notification options

You can trigger a notification to run on the following host/service states.

SyntaxDefinition
Host Notifications
DDown
UUp
RRecovery
FFlapping
SScheduled Downtime
Service Notifications
WWarning
UUnknown
CCritical
FFlapping
SScheduled Downtime
RRFecovery
NNull

Import Nagios hosts as assets in SysAid

The third script you generate in SysAid allows you to import all of the hosts defined in Nagios into SysAid Asset Management.

  1. Transfer the "send_host_list_to_sysaid.bash" script file to a folder in Nagios.
  2. Change the access permissions on the secripts to allow their execution, using chmod:
    ActionScript
    chmod +x send_host_list_to_sysaid.bash
  3. Run the script as follows:
    ActionScript
    ./send_host_list_to_sysaid.bash
Note: 
It is recommended to to set up a scheduled cron job to import assets on a regular basis.

Was this article helpful?