Nagios Webhook

You can configure the Nagios webhook to post notifications to the Events API when events of interest occur.

Before you begin

This integration was validated with Nagios v5.7.3.

Before you start to set up your integration, make sure:

  • You have an active Nagios account.

  • You have the necessary permissions to create alerts and notifications channels in Nagios.

  • Nagios can make requests to external endpoints over port 443. This is the default.

  • You have created a Moogsoft API key and have access to a copy of it.

  • You have copied the Events Endpoint URL from Data Config > Ingestion Services > Events API in Moogsoft.

    Events_URL.png
  • You have downloaded the send_to_moogsoft.sh script.

Initial Configuration

To prepare your Nagios instance for integration with Moogsoft, do the following:

  1. Edit the send_to_moogsoft.sh script and update the following variables.

    1. MOOGSOFT_URL: Enter the Moogsoft Events Endpoint URL.

    2. MOOGSOFT_API_KEY: Enter your Moogsoft API key.

  2. Copy the send_to_moogsoft.sh script to the /usr/local/nagios/libexec folder of your Nagios server.

  3. Make the script executable:

    chmod +x send_to_moogsoft.sh
  4. Change the ownership of the send_to_moogsoft.sh to apache:nagios.

Creating Notification Commands in Nagios

To create a host notification command in Nagios, do the following:

  1. Navigate to Configure > Core Config Manager.

  2. Click Commands in the CCM Object summary pane.

  3. Click + Add New.

  4. In the Command Name field, enter send-host-event-moogsoft.

  5. In the Command Line field, enter the following:

    /usr/local/nagios/libexec/send_to_moogsoft.sh HOST "$HOSTNAME$" "$HOSTALIAS$" $TIMET$ "$HOSTCHECKCOMMAND$" $HOSTSTATEID$ "$HOSTOUTPUT$" $HOSTSTATETYPE$ "state_type:$HOSTSTATETYPE$" "desc:$HOSTDESC$" "last_ok:$LASTHOSTOK$" "$HOSTADDRESS$"
  6. On the Command Type menu, click misc command.

  7. Click Save.

Creating a Service Notification Command in Nagios

To create a service notification command in Nagios, do the following:

  1. Navigate to Configure > Core Config Manager.

  2. Click Commands in the CCM Object summary pane.

  3. Click + Add New.

  4. In the Command Name field, enter send-service-event-moogsoft.

  5. In the Command Line field, enter the following:

    /usr/local/nagios/libexec/send_to_moogsoft.sh SERVICE "$HOSTNAME$" "$HOSTALIAS$" $TIMET$ "$SERVICECHECKCOMMAND$" $SERVICESTATEID$ "$SERVICEOUTPUT$" $SERVICESTATETYPE$ "state_type:$SERVICESTATETYPE$" "desc:$SERVICEDESC$" "last_ok:$LASTSERVICEOK$" "$HOSTADDRESS$"
  6. In the Command Type list, click misc command.

  7. Click Save.

  8. Click Apply Configuration.

Create a Notification Contact Group

To create a Moogsoft Contact Group in Nagios, do the following:

  1. Navigate to Configure > Core Config Manager.

  2. Click Alerting in the side panel.

  3. Click Contact Groups.

  4. Click + Add New.

  5. In the Contact Group Name field, enter moogsoft.

  6. In the Alias field, enter Send notifications to Moogsoft.

  7. Click Save.

  8. Click Apply Configuration.

Create a Moogsoft Contact and Configure Notification Settings

To create a Moogsoft Contact and configure notification settings in Nagios, do the following:

  1. Navigate to Configure > Core Config Manager.

  2. Click Alerting.

  3. Click Contacts.

  4. Click + Add New.

  5. In the Contact Name field, enter moogsoft.

  6. (Optional): Add a Description for the contact.

  7. Click Manage Contact Groups.

  8. Add the moogsoft Contact Group to the Assigned list.

  9. Click Close.

  10. Click the Alert Settings tab.

  11. Set Host Notifications Enabled to On.

  12. Set the preferred notification time period via the Host Notifications Timeperiod dropdown.

  13. Set Host Notifications Options to Down, Unreachable, Up, Flapping, and Scheduled Downtime.

  14. Click Manage Host Notification Commands.

  15. Add the send-host-event-moogsoft command to the Assigned list.

  16. Click Close.

  17. Set Service Notifications Enabled to On.

  18. Set the preferred notification time period via the Service Notifications Timeperiod dropdown.

  19. Set Service Notifications Options to Warning, Unknown, Critical, Flapping, Scheduled Downtime, and Ok.

  20. Click Manage Service Notification Commands.

  21. Add the send-service-event-moogsoft command to the Assigned list.

  22. Click Close.

  23. Click Save.

  24. Click Apply Configuration.

Assign the Contact Group to the Host and Service Templates

Next, apply the contact group and associated notification settings to the relevant host and service templates used for monitoring in your environment. This examples uses the xiwizard_generic_host and xiwizard_generic_service templates as created and assigned by the Nagios XI auto-discovery function, but you need to ensure that notification is enabled for each template in use in your environment.

  1. Navigate to Configure > Core Config Manager.

  2. Click Templates > Host Templates.

  3. From the list of templates, select xiwizard_generic_host.

  4. Click the Alert Settings tab.

  5. Click Manage Contact Groups.

  6. Add the moogsoft Contact Group to the Assigned list.

  7. Click Save.

  8. Click Apply Configuration.

  9. Navigate to Configure > Core Config Manager.

  10. Click Templates > Service Templates.

  11. From the list of templates select xiwizard_generic_service.

  12. Click the Alert Settings tab.

  13. Add the moogsoft Contact Group to the Assigned list.

  14. Click Save.

  15. Click Apply Configuration.