• Get started
  • Documentation

Integrate Opsgenie with Nagios XI Plugin

How does the integration work?

  • When a host or service state becomes down in Nagios XI, an alert is created in Opsgenie.

  • Upon creating the new alert, related histogram and trends images from Nagios XI are automatically attached to the alert.

  • When the Opsgenie alert is acknowledged, the alert in Nagios XI is also acknowledged automatically, and vice versa.

  • When a note is added to the Opsgenie alert, the alert in Nagios XI is also updated automatically, and vice versa.

Set up the integration

The Nagios XI integration plugin utilizes the full capabilities of Opsgenie and provides bi-directional integration with Nagios XI. The steps in the following procedure describe how to integrate Opsgenie and Nagios XI using the Nagios XIintegration plugin. Note that slight alteration to these instructions may be necessary depending on the exact Linux distribution and your Nagios XI configuration.

Installation prerequisites

The installation packages support the following systems:

  • RedHat-based Linux distributions

  • Debian-based Linux distributions

Install the Opsgenie plugin for Nagios XI

Opsgenie Edge Connector (OEC) is a prerequisite for configuring the outgoing authentication of Nagios XI integration. You can combinedly use OEC and Nagios XI scripts to update alerts on Nagios XI. With this setup, you can deploy your own script, modify the ones provided, or run customized actions on Nagios XI. Download the latest version of the Nagios XI package from this repository.

Instructions for RedHat-based distributions

Run the following command: 

rpm -i opsgenie-nagiosxi-<your_version>.rpm

Before rpm upgrades, back up your configuration files.

The rpm package does not overwrite the existing configuration during upgrades. It saves the new default configuration file as integration.conf.rpmnew. Add the-- force parameter to upgrade from version 201X-XX-XX to 2.X.X. For example: rpm -U --force opsgenie-nagiosxi-<your_version>.rpm

Learn more about config file handling for rpm upgrades.

Instructions for Debian-based distributions

Run the following command: 

dpkg -i opsgenie-nagiosxi-<your_version>.deb

Add a Nagios XI integration

If you're using Opsgenie's Free or Essentials plan or if you’re using Opsgenie with Jira Service Management's Standard plan, you can add this integration from your team dashboard only. The Integrations page under Settings is not available in your plan.

  1. Go to Teams and select your team.

  2. Select Integrations on the left navigation and then select Add integration.

Adding the integration from your team dashboard will make your team the owner of the integration. This means Opsgenie will assign the alerts received through this integration to your team only. Follow the rest of the steps in this section to set up the integration.

To add a Nagios XI integration in Opsgenie:

  1. Go to Settings > Integrations.

  2. Select Add integration.

  3. Run a search and select “Nagios XI”.

  4. On the next screen, enter a name for the integration.

  5. Optional: Select a team in Assignee team if you want a specific team to receive alerts from the integration.

  6. Select Continue.
    The integration is saved at this point.

  7. Expand the Steps to configure the integration section and copy the URL.
    You will use this URL while configuring the integration in Nagios XI later.

  8. Select Turn on integration.
    The rules you create for the integration will work only if you turn on the integration.

Configure the Opsgenie plugin in Nagios XI

The plugin uses a golang-executable file (included in the plugin as send2opsgenie) to create, acknowledge, and close alerts in Opsgenie. To make send2opsgenie work, you need to make some configurations. The following table lists the parameters and states if they are mandatory. Setting the apiKey is required. Other configuration parameters are set to their default values that work with most Nagios XI implementations but may also need to be modified.

Configuration Parameters

Description

Mandatory to fill

Location

apiKey

Copy the API key from the Nagios XI integration you've created above. send2opsgenie uses this key to authenticate to Opsgenie. API key is also used to identify the right integration configuration that should be used to process alerts.

Yes

/home/opsgenie/oec/conf/config.json

baseUrl

If you're using Opsgenie from another domain(eg. EU, sandbox), you should update this configuration.Opsgenie NagiosXI integration, Advanced Settings page.

Optional

/home/opsgenie/oec/conf/config.json

responders

Responders field is used to specify which teams should be notified for the Nagios XI alerts. This field is used to set the default teams field value. It can be modified to route different alerts to different teams in Opsgenie Nagios XI integration, Advanced Settings page.

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

tags

Tags field is used to specify the tags of the alert that created in Opsgenie.

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

nagios_server

nagios_server field is used to identify the Nagios XIserver in Opsgenie, and only required when there are multiple Nagios XI servers. This field is used by Opsgenie when sending actions executed by users (acknowledge, close, etc.) back to your Nagios XI servers via OEC

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

logPath

Specifies the full path of the log file. (Default value is /var/log/opsgenie/send2opsgenie.log)

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

nagios2opsgenie.http.proxy.enabled

nagios2opsgenie.http.proxy.enabled field is to enable/disable external proxy configuration. The default value is false.

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

nagios2opsgenie.http.proxy.host

It is the host of the proxy.

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

nagios2opsgenie.http.proxy.port

It is the port of the proxy.

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

nagios2opsgenie.http.proxy.scheme

It is the proxy connection protocol. It may be http or https depending on your proxy servers. Its default value is http.

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

nagios2opsgenie.http.proxy.username

It is the Proxy authentication username.

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

nagios2opsgenie.http.proxy.password

It is the Proxy authentication password.

Optional

/home/opsgenie/oec/conf/opsgenie-integration.conf

Configure the golang-executable file in any of the following three methods:

Method 1: Configure from conf file

Configure from the /home/opsgenie/oec/conf/integration.conf file. This overwrites any configuration you previously made in the script.

Method 2: Configure by using Golang flags

Configure by entering flags into the command from the Nagios XI web interface through Configure > Core Config Manager > Commands. Use -apiKey flag for your apiKey and -ns flag for your nagios_server name. If you don't have multiple Nagios servers, you don't have to define the Nagios server. Using flags overwrites all the other configuration methods mentioned earlier.

To send additional custom arguments, add them after the flags. For example, customArgName1 customArgValue1 customArgName2 customArgValue2. Parse custom arguments by adding {{_payload.customArgName}} to wherever is needed in the input fields. To learn more about using raw parameters, see dynamic fields.

Method 3: Configure from script

Configure apiKey and nagios_server from the send2opsgenie.go script. Build the script again and put the new executable into the /home/opsgenie/oec/scripts directory. Learn more about the location of the send2opsgenie.go and how to build a go script in the “Source for and recompiling send2opsgenie” section in this article.

Define Nagios XI commands

1. Create and configure host and service notification commands with the following content from Nagios XI web interface through Configure > Core Config Manager > Commands.

2. Define the host command:
Command name: notify-host-by-opsgenie
Command type: misc command
Command line:

1 /home/opsgenie/oec/scripts/send2opsgenie -entityType=host -t="$NOTIFICATIONTYPE$" -ldt="$LONGDATETIME$" -hn="$HOSTNAME$" -hdn="$HOSTDISPLAYNAME$" -hal="$HOSTALIAS$" -haddr="$HOSTADDRESS$" -hs="$HOSTSTATE$" -hsi="$HOSTSTATEID$" -lhs="$LASTHOSTSTATE$" -lhsi="$LASTHOSTSTATEID$" -hst="$HOSTSTATETYPE$" -ha="$HOSTATTEMPT$" -mha="$MAXHOSTATTEMPTS$" -hei="$HOSTEVENTID$" -lhei="$LASTHOSTEVENTID$" -hpi="$HOSTPROBLEMID$" -lhpi="$LASTHOSTPROBLEMID$" -hl="$HOSTLATENCY$" -het="$HOSTEXECUTIONTIME$" -hd="$HOSTDURATION$" -hds="$HOSTDURATIONSEC$" -hdt="$HOSTDOWNTIME$" -hpc="$HOSTPERCENTCHANGE$" -hgn="$HOSTGROUPNAME$" -hgns="$HOSTGROUPNAMES$" -lhc="$LASTHOSTCHECK$" -lhsc="$LASTHOSTSTATECHANGE$" -lhu="$LASTHOSTUP$" -lhd="$LASTHOSTDOWN$" -lhur="$LASTHOSTUNREACHABLE$" -ho="$HOSTOUTPUT$" -lho="$LONGHOSTOUTPUT$" -hnu="$HOSTNOTESURL$" -hpd="$HOSTPERFDATA$"

3. Define the service command.
Command name: notify-service-by-opsgenie
Command type: misc command
Command line:

1 /home/opsgenie/oec/scripts/send2opsgenie -entityType=service -t="$NOTIFICATIONTYPE$" -ldt="$LONGDATETIME$" -hn="$HOSTNAME$" -hdn="$HOSTDISPLAYNAME$" -hal="$HOSTALIAS$" -haddr="$HOSTADDRESS$" -hs="$HOSTSTATE$" -hsi="$HOSTSTATEID$" -lhs="$LASTHOSTSTATE$" -lhsi="$LASTHOSTSTATEID$" -hst="$HOSTSTATETYPE$" -ha="$HOSTATTEMPT$" -mha="$MAXHOSTATTEMPTS$" -hei="$HOSTEVENTID$" -lhei="$LASTHOSTEVENTID$" -hpi="$HOSTPROBLEMID$" -lhpi="$LASTHOSTPROBLEMID$" -hl="$HOSTLATENCY$" -het="$HOSTEXECUTIONTIME$" -hd="$HOSTDURATION$" -hds="$HOSTDURATIONSEC$" -hdt="$HOSTDOWNTIME$" -hpc="$HOSTPERCENTCHANGE$" -hgn="$HOSTGROUPNAME$" -hgns="$HOSTGROUPNAMES$" -lhc="$LASTHOSTCHECK$" -lhsc="$LASTHOSTSTATECHANGE$" -lhu="$LASTHOSTUP$" -lhd="$LASTHOSTDOWN$" -lhur="$LASTHOSTUNREACHABLE$" -ho="$HOSTOUTPUT$" -lho="$LONGHOSTOUTPUT$" -hpd="$HOSTPERFDATA$" -s="$SERVICEDESC$" -sdn="$SERVICEDISPLAYNAME$" -ss="$SERVICESTATE$" -ssi="$SERVICESTATEID$" -lss="$LASTSERVICESTATE$" -lssi="$LASTSERVICESTATEID$" -sst="$SERVICESTATETYPE$" -sa="$SERVICEATTEMPT$" -msa="$MAXSERVICEATTEMPTS$" -siv="$SERVICEISVOLATILE$" -sei="$SERVICEEVENTID$" -lsei="$LASTSERVICEEVENTID$" -spi="$SERVICEPROBLEMID$" -lspi="$LASTSERVICEPROBLEMID$" -sl="$SERVICELATENCY$" -set="$SERVICEEXECUTIONTIME$" -sd="$SERVICEDURATION$" -sds="$SERVICEDURATIONSEC$" -sdt="$SERVICEDOWNTIME$" -spc="$SERVICEPERCENTCHANGE$" -sgn="$SERVICEGROUPNAME$" -sgns="$SERVICEGROUPNAMES$" -lsch="$LASTSERVICECHECK$" -lssc="$LASTSERVICESTATECHANGE$" -lsok="$LASTSERVICEOK$" -lsw="$LASTSERVICEWARNING$" -lsu="$LASTSERVICEUNKNOWN$" -lsc="$LASTSERVICECRITICAL$" -so="$SERVICEOUTPUT$" -lso="$LONGSERVICEOUTPUT$" -snu="$SERVICENOTESURL$" -spd="$SERVICEPERFDATA$"

4. Select Apply New Configuration for the changes to take effect.

Define Nagios XI Contacts

  1. Go to Configure > Core Config Manager > Contacts.

  2. Select Add New.

  3. Populate the Common Settings as follows:
    Contact Name: opsgenie
    Description: Opsgenie Contact

  4. Select the Active checkbox.

  5. Populate alert settings:

Host Notifications Enabled

Checked

Host Notification Timeperiod:

24×7

Host Notification options:

down, unreachable (depending on the use case other options can be selected as well)

Manage Host Notification Commands:

Add notify-host-by-opsgenie command to selected list

Service Notifications Enabled:

checked

Service Notification Timeperiod:

24×7

Service Notification options:

critical (depending on the use case other options can be selected)

Manage Service Notification Commands:

Add notify-service-by-opsgenie command to selected list

Select Save and Apply Configuration.

Ensure that the contact is added to your Hosts and Services contact list. If everything goes well, you will see alerts in Opsgenie for every notification created in Nagios XI. When the host or service comes back up, the alert in Opsgenie gets closed automatically as well.

If you face any problems, check the send2opsgenie logs and the FAQ and troubleshooting section. Contact us with the logs if needed.

Configure Opsgenie to update Nagios XI

This is an optional step.

Select the Send Alert Actions To Nagios XI checkbox on the integration configuration page. You can combinedly use OEC and Nagios XI scripts to update alerts on Nagios XI. With this setup, you can deploy your own script, modify the ones provided, or run customized actions on Nagios XI.

To run actions in Nagios XI, OEC gets the configuration parameters from the configuration file, config.json (found at /home/opsgenie/oec/conf/oec-config.json).

Configuration parameters

  • alert_histogram_image_url: OEC retrieves histogram images from Nagios XI using this URL. Localhost should be replaced with the Nagios server address.

  • trends_image_url: OEC retrieves trends images from Nagios XI using this URL. Localhost should be replaced with the Nagios server address.

  • command_url: URL to update Nagios XI alerts when alerts get acknowledged, commented, etc.

  • user: Username to authenticate Nagios XI web server to get Nagios histogram and trends images.

  • password: Password to authenticate Nagios XI web server to get Nagios histogram and trends images.

The downloaded package includes the OEC utility (found in /usr/local/bin) and the script that OEC needs to run (found in /home/opsgenie/oec/scripts). Be sure to run OEC after configuring it. Learn more about running OEC documentation. If using OEC, rich alerts are populated with host or service current status information in Opsgenie for every notification created in Nagios XI.

The Nagios XI integration package does not support SSL v1.0. If your Nagios XI server has SSL v1.0, upgrade your SSL server.

Source for and recompiling send2opsgenie

The source for the executable send2opsgenie is found in /usr/bin/ and send2opsgenie.go, in /home/opsgenie/oec/scripts respectively, and is also available in this repository. To change the behavior of the executable, edit send2opsgenie.go and build it by using the following command: go build send2opsgenie.go

For installing go, refer to http://golang.org/doc/install. Note that the executable in the plugin is built for linux/386 systems.

FAQ and troubleshooting

If the integration is not working, review this section and follow the prescribed guidelines.

1. Nagios alerts are not getting created in Opsgenie

Run the following test command from the shell and check if a test alert is created in Opsgenie

1 /home/opsgenie/oec/scripts/send2opsgenie -entityType=host -t=PROBLEM -hs=DOWN -hn=test_host
  • If you get a "Trace/breakpoint trap" error, the send2opsgenie plugin isn't compatible with the server distribution. Rebuild send2opsgenie.go according to the specific server environment as described in the “Source for and recompiling send2jopsgenie” section in this article.

  • If the alert is created in Opsgenie, the integration is configured correctly. Nagios XI is probably not notifying the Opsgenie contact for alerts. Check your Nagios XI alert notifications log.

  • If the alert is not created in Opsgenie, check the logs at /var/log/oec/send2opsgenie.log.
    Look for the following errors in the log file:

    • If you see "RestException[Could not authenticate.]" in the logs, Opsgeniecouldn't identify the API key. Check if the API key is set correctly per the steps outlined in the “Configure the Opsgenie plugin in Nagios XI” section of this article.

    • If unsure of the problem, set the plugin's log level to debug and try again. Contact us and share the logs.

  • If there is no /var/log/oec/send2opsgenie.log file or there are no logs in it, check the following:

    1. Check if the Nagios user has permission to write to /var/log/oec directory. The installation package should automatically do this for you. If you face issues, run the following command: 
      chown -R nagios:opsgenie /var/log/oec

    2. Check the Nagios server logs at /opt/nagios/log/zeneventd.log. See if there are error logs regarding send2opsgenie. Contact us with the logs if needed.

Set send2opsgenie plugin's log level to DEBUG

Set the send2opsgenie plugin's log level to DEBUG. Open the /home/opsgenie/oec/conf/integration.conf file and change the line send2opsgenie.logger=warning to nagios2opsgenie.logger=debug.

2. The Nagios alert is not acknowledged when the alert is acknowledged in Opsgenie

Check the alert logs.

  • If "Posted [Acknowledge] action to Nagios XI.." is not present in the log, Opsgenie didn't send the Acknowledge action to Nagios XI. Check the integration configuration, it might not have a matching the alert action.

  • If only the "Posted [Acknowledge] action to Nagios XI.." log occurs followed by no related logs, it might mean OEC is having connection problems. Check the logs.

3. Could not open Nagios RPM package

  • If you figure out while installing the rpm package that the package is obsolete, use rpm -i opsgenie-nagiosxi-1.0.4-rpm-x86-64.rpm --nodeps instead.

  • If you get "is already installed" error, use rpm -i opsgenie-nagiosxi-1.0.4-rpm-x86-64.rpm --force instead.

4. Permission error occurs while attaching zip file to alert in script

If you get "PermissionError: [Errno 13] Permission denied: details_*" error while running the script, prefix the path of the script to the "file_name" variable in the attach method of the script.

Still need help?

The Atlassian Community is here for you.