Nagios monitoring integration

The Nagios integration collects the responses of your existing service checks and reports them to New Relic Infrastructure. This document explains how to install and configure the Nagios integration and describes the data collected.

This integration is released as Open Source under the MIT license on GitHub. A change log is also available there for the latest updates.

Access to this feature depends on your subscription level. Requires Infrastructure Pro.

Features

The Nagios on-host integration allows you to utilize your existing service checks directly, without the need to run Nagios instance.

Compatibility and requirements

To use the Nagios integration, ensure your system meets these requirements:

Install

On-host integrations do not automatically update. For best results, you should occasionally update the integration and update the Infrastructure agent.

To install the Nagios integration:

Linux installation
  1. Follow the instructions for installing an integration, using the file name nri-nagios.
  2. Via the command line, change directory to the integrations folder:
    cd /etc/newrelic-infra/integrations.d
  3. Create a copy of the sample configuration file by running:
    sudo cp nagios-config.yml.sample nagios-config.yml
  4. Create a copy of the sample service checks file by running:
    sudo cp nagios-service-checks.yml.sample nagios-service-checks.yml
  5. Edit the nagios-config.yml configuration file using the configuration settings.
  6. Restart the infrastructure agent.
Windows installation
  1. Download the nri-nagios .MSI installer image from:

    http://download.newrelic.com/infrastructure_agent/windows/integrations/nri-nagios/nri-nagios-amd64.msi

  2. Run the install script. To install from the Windows command prompt, run:
    msiexec.exe /qn /i PATH\TO\nri-nagios-amd64.msi
  3. In the Integrations directory, C:\Program Files\New Relic\newrelic-infra\integrations.d\, create a copy of the sample configuration file by running:

    cp nagios-config.yml.sample nagios-config.yml
  4. Edit the nagios-config.yml configuration file using the configuration settings.
  5. In the Integrations directory, C:\Program Files\New Relic\newrelic-infra\integrations.d\, create a nagios-service-checks.yml file that describes the service checks to be run by the integration.

    For an example configuration, see the example service checks file.

  6. Restart the infrastructure agent.

You can also manually install integrations from a tarball file. For more information, see Install manually from a tarball archive.

Configure

Use the Nagios integration's nagios-config.yml configuration file to put required login credentials and configure how data is collected. For an example configuration, see the example config file.

Arguments

The nagios-config.yml contains only one configurable argument:

service_checks_config: This points to a yaml file containing definitions of the service checks that will be run by the integration.

Commands

The service_checks_config yaml file contains the top-level array service_checks. Each service check must contain both a name and a command.

Key Description

name

The naming convention is not specific, and allows for easy recognition in the Infrastructure UI.

command

The command is an array of strings, with the first position containing the path to the executable and the remaining positions containing the arguments to the executable.

labels

A collection of key: value pairs which help to identify and group service checks in Insights.

parse_output

Attempts to parse the output of service checks that conform to the Nagios Plugin API spec. Default: false.

Permissions

Non-configurable commands are run by the Infrastructure agent, which itself is run by the root user. For the integration to run properly, ensure that the permissions on the yaml file are appropriately restrictive as indicated below:

Linux permissions

Set the user permissions flag to 0600, restricting read and write privileges to the file owner. If permissions do not meet this requirement, an error will be logged and the integration will fail to run.

Windows permissions

By default, the agent and any commands in the yaml file run as an Administrator. As the integration is unable to check permissions, it is up to the user to appropriately restrict permissions for the file.

Example file configurations:

Example nagios-config.yml configuration
integration_name: com.newrelic.nagios

instances:
  - name: nagios
    # Command can only be metrics
    command: metrics
    arguments:
      # The absolute path to the service checks config file
      service_checks_config: /etc/newrelic-infra/integrations.d/nagios-service-checks.yml
Example nagios-service-checks.yml configuration
service_checks:
  - name: check_users
    command: ["/usr/local/nagios/libexec/check_users", "-w", "5", "-c", "10"]
    parse_output: true
    labels:
      env: staging
      key1: val1
  - name: check_yum
    command: ["/usr/local/nagios/libexec/check_yum"]

Find and use data

To find your integration data in Infrastructure, go to infrastructure.newrelic.com > Third-party services and select one of the Nagios integration links.

In New Relic Insights, Nagios data is attached to the NagiosServiceCheckSample Insights event type.

For more on how to find and use your data, see Understand integration data.

Metric data

The Nagios integration collects the following metric data attributes.

These attributes can be found by querying the NagiosServiceCheckSample event types in Insights.

Metric Description

serviceCheck.command

The command used to run the service check.

serviceCheck.error

The standard error (stderr) output of the service check.

serviceCheck.longServiceOutput

The portion of the message that is parsed by Nagios as $LONGSERVICEOUTPUT$. Only enabled if parse_output is set.

serviceCheck.message

The standard output (stdout) of the service check.

serviceCheck.name

The descriptive name of the service check being performed.

serviceCheck.serviceOutput

The portion of the message that is parsed by Nagios as $SERVICEOUTPUT$. Only enabled if parse_output is set.

serviceCheck.status

The return code of the service check. Options:

  • 0 = Ok
  • 1 = Warning
  • 2 = Critical
  • 3 = Unknown

*

Any additional metrics defined and reported by the service check. Only enabled if parse_output is set.

Troubleshooting

Troubleshooting tips:

Config parsing failed error

The following error appears in the log file:

Config parsing failed: service checks file permissions are not restrictive enough. Required file permissions are 0600. See documentation for details

Solution:

Set the user permissions flag to 0600, restricting read and write privileges to the file owner.

Cause:

If the file is not owned by the root user or the file can be written to by a user other than the root user, the integration will allow users to run arbitrary commands as though they are a root user. If permissions do not meet the requirement, an error will be logged and the integration will fail to run.

For more help

Recommendations for learning more: