• Products
  • Get started
  • Documentation
  • Resources

Integrate Opsgenie with Nagios XI Plugin

Opsgenie provides a Nagios XI Integration package that utilizes full capabilities of Opsgenie, including rich alerts with charts, automated closing of alerts, and bi-directional integration with Nagios. When installed and appropriately configured, the plugin creates Opsgenie alerts when a Nagios XI notification is sent, and by using OEC utility, attaches extra information (status, alert histogram, trends, etc. ) related with the relevant host or service. This extra information can be viewed with the alert directly from Opsgenie apps.

Installation

Nagios XI integration plugin. Note that you may need to slightly alter these instructions depending on your exact Linux distribution and your Nagios XI configuration.

If you're using Lamp based Nagios XI plugin, you should backup all your configurations. Uninstall the old plugin, then install the new one.

Prerequisites

Packages are provided for Red Hat and Debian based linux distributions.

  • Red Hat based linux distributions

  • Debian based linux distributions

Install Opsgenie Nagios XI Plugin

Download the latest version of OEC

To download the latest version of Nagios XI package, please use readme file of oec-scripts repository.

 

For Red Hat Based Distributions

  • Run the following command:

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

During upgrades, rpm package does not overwrite your existing configurations. It saves the new default configuration file as opsgenie-integration.conf.rpmnew. You can find more information about rpm upgrade config file handling from here.

If you want to update from version 201X-XX-XX to 2.X.X, you must add --force parameter. E.g.:

rpm -U --force opsgenie-integration-<your_version>.rpm

We suggest that you backup your configuration files before update!

For Debian Based Distributions

  • Run the following command:
    dpkg -i opsgenie-nagiosxi-<your_version>.deb

Add Nagios XI Integration in Opsgenie

  1. Go to Settings > Integrations. Search for Nagios XI and select Add.

  2. Edit the details of the integration then select Save Integration. We’ll generate an API Key for this integration. This key will be used by Nagios XI to authenticate with Opsgenie and specify the integration that should be used to process Nagios XI alerts.

Nagios XI plugin

Opsgenie Nagios XI Plugin Configuration

The plugin uses a golang-executable file (included in the plugin as send2opsgenie) to create, acknowledge and close alerts in Opsgenie. Nagios XI is configured to execute this file on events to create, acknowledge and close alerts in Opsgenie.

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

There are three ways to configure golang-executable file:

  1. Configuring from conf file: You can configure from /home/opsgenie/oec/conf/opsgenie-integration.conf and /home/opsgenie/oec/conf/config.json files. Configuring from conf file will overwrite the configurations made in the script.

  2. Configuring by using Golang Flags: You can configure by entering flags to command from 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 will overwrite all the other configuration methods mentioned above.

If you want to send additional custom arguments, you can add them after the flags as: customArgName1 customArgValue1 customArgName2 customArgValue2
You can parse custom arguments by adding {{_payload.customArgName}} to wherever you need on the input fields.
For more information about using raw parameters please visit Dynamic Fields document.

3. Configuring from script: You can configure apiKey and nagios_server from send2opsgenie.go script. If you use this option, you need to build the script again and put the new executable to /home/opsgenie/oec/opsgenie-nagiosxi directory. You can find information about the location of the send2opsgenie.go and how to build a go script in the "Source" section.

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 Host Command.

Command Name: notify-host-by-opsgenie

Command Type: misc command

Command Line:

Text

1 /home/opsgenie/oec/opsgenie-nagiosxi/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$"
Nagios XI Command Management

3. Define Service Command.

Command Name: notify-service-by-opsgenie

Command Type: misc command

Command Line:

Text

1 /home/opsgenie/oec/opsgenie-nagiosxi/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$"
NagioXI Service Command

4. After adding commands don't forget to press Apply New Configuration for the changes to take effect.

Define Nagios XI Contacts

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

  2. Click on Add New button

  3. Populate Common Settings as follows.

Contact Name: opsgenie

Description: Opsgenie Contact

Active: checked

NagioXI Contact Management

4. Populate Alert Settings as follows:

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

NagioXI Contact Alert Settings

5. Click on Save and Apply Configuration buttons.

Please make sure 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 have any problem, check send2opsgenie logs and Troubleshoot Guide for common problems. Please don't hesitate to contact us, if your problem persists.

Configure Opsgenie to Nagios XI Integration (Optional)

In order to use this feature "Send Alert Actions To Nagios XI" checkbox should be enabled in Opsgenie Nagios XI Integration.

Use Opsgenie’s OEC and the Nagios XI script to update alerts on Nagios XI. This enables deployment of your own scripts/ability to modify the ones provided and execute customized actions on Nagios XI.

To be able to execute actions in Nagios XI, OEC gets the configuration parameters from the configuration file. The configuration file can be found under /home/opsgenie/oec/conf/config.json.

Configuration parameters

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

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

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

  • user & password: Credentials to authenticate NagiosXI web server.

The package that you downloaded also includes OEC utility which is located under /usr/local/bin and the script that is needed to be run by OEC which is under /home/opsgenie/oec/scripts. After the configuration of OEC is done, you need to run it. In order to learn more about how to run OEC, you can refer to the Running OEC documentation.

Nagios XI rich alert
Nagios XI attachment

Nagios XI integration package does not support SSL v1.0. If your Nagios XI Server has SSL v1.0, we suggest you to upgrade your SSL server.

FAQ and Troubleshooting

If you're having trouble getting the integration to work, please check if your problem is mentioned below, and follow our advice:

1- Nagios XI alerts are not getting created in Opsgenie:

Run the following test command from the shell. Check if the test alert is created in Opsgenie:

/home/opsgenie/oec/opsgenie-nagiosxi/send2opsgenie -entityType=host -t=PROBLEM -hs=DOWN -hn=test_host

If you're getting a "Trace/breakpoint trap" error: It means your send2opsgenie plugin isn't compatible with your server distribution. Follow the "Source and Recompiling send2opsgenie" section below and rebuild your send2opsgenie.go according to your specific server environment.

If the alert is created in Opsgenie: It means the integration is installed correctly. The problem might be that Nagios is not notifying the Opsgenie contact for alerts. Check your Nagios alert notifications log.

If not: Check the logs at /var/log/opsgenie/send2opsgenie.log. Look for the following errors in the log file:

  • If you're seeing "RestException[Could not authenticate.]" in the logs, it means Opsgenie couldn't identify your api key. Check if you've set the API key correctly, as explained in "Opsgenie NagiosXI Plugin Configuration" above.

  • If you're seeing "Could not execute this action with apiKey of [NagiosXI] integration" in the logs, you might have downloaded the wrong integration package. Make sure that you download the Nagios XI integration package, not Nagios or any other.

  • If you can't make sense of the problem, set the plugin's log level to debug, try again and send the logs to us with our contact us form.

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

  1. First, make sure the Nagios user has permission to write to /var/log/opsgenie directory. The installation package should automatically do this for you. If you encounter problems, execute:
    chown -R nagios:opsgenie /var/log/opsgenie

  2. Now check your Nagios server logs at /usr/local/nagios/var/nagios.log. See if there are error logs regarding send2opsgenie, and contact us with them.

Setting send2opsgenie plugin's log level to DEBUG:

Change the line nagios2opsgenie.logger=warning to nagios2opsgenie.logger=debug in /home/opsgenie/oec/conf/opsgenie-integration.conf file.

2- The Nagios XI alert is not acknowledged when you ack the alert at Opsgenie:

  1. First, check your alert logs.

  • If you don't see the "Posted [Acknowledge] action to NagiosXI.." log, it means Opsgenie didn't send the Acknowledge action to Nagios XI. Check your integration configuration, it might not have matched the alert action.

  • If you only see the "Posted [Acknowledge] action to Nagios XI.." log and no related log after that, it might mean OEC is having connection problems. Check the logs.

3. Could not open Nagios XI RPM package

If while installing the rpm package you get an error saying that the package is obsolated, you need to 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 are getting "PermissionError: [Errno 13] Permission denied: details_*" error while running the script, prepend the path of the script to the "file_name" variable in the attach method of the script.

Source and Recompiling send2opsgenie

The source for the executable send2opsgenie is located under /home/opsgenie/oec/opsgenie-nagiosxi* and send2opsgenie.go is located under /home/opsgenie/oec/opsgenie-nagiosxi** and is also available at GitHub OpsGenie Integration repository. If you wish to change the behavior of the executable, you can edit send2opsgenie.go and build it using:

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.

Additional Help