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.

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

This on-host integration has been contributed to the New Relic GitHub under an MIT license.

Features

The Nagios on-host integration allows you to utilize your existing service checks directly, without the need for a running 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:

  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.

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.

Metric 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.

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"]
    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 > Integrations > On-host integrations 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 stderr output of the service check.

servicecheck.message

The stdout output of the service check.

servicecheck.name

A descriptive name of the service check.

servicecheck.status

The return code of the service check. Options:

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

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:

  • See the Docs site's landing page for Infrastructure integrations documentation.
  • Browse New Relic's Explorers Hub for community discussions about New Relic Infrastructure integrations.
  • Use your preferred search engine to find other New Relic resources.