Nagios monitoring integration

Our Nagios integration lets you use your service checks directly, without the need to run a Nagios instance.

Read on to install the integration, and to see what data we collect.

Compatibility and requirements

Our integration is compatible with any existing service that conform to the Nagios Plugin API.

Before installing the integration, make sure that you meet the following requirements:

This integration is released as open source under the MIT license on GitHub.

Install and activate

To install the Nagios integration:

Linux installation
  1. Follow the instructions for installing an integration, using the file name nri-nagios.
  2. Change directory to the integrations folder:
    cd /etc/newrelic-infra/integrations.d
  3. Copy of the sample configuration file:
    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 file as described in 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. 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 file as described in 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.

Additional notes:

Configure the integration

An integration's YAML-format configuration is where you can place required login credentials and configure how data is collected. Which options you change depend on your setup and preference.

For an example configuration, see the example config file.

Arguments

The nagios-config.yml contains two configurable arguments:

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

  • concurrency: The number of services checks to be run concurrently (Default: 1).

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"]

For more about the general structure of on-host integration configuration, see Configuration.

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: