---
title: Nagios monitoring integration
source: https://docs.newrelic.com/docs/infrastructure/host-integrations/host-integrations-list/nagios-monitoring-integration
---

Our Nagios [integration](https://docs.newrelic.com/docs/integrations/host-integrations/getting-started/introduction-host-integrations) 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 [#comp-req]

Our integration is compatible with any existing service that conform to the [Nagios Plugin API](https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/pluginapi.html).

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

-   [Install the infrastructure agent](https://docs.newrelic.com/docs/infrastructure/install-infrastructure-agent/get-started/install-infrastructure-agent-new-relic).
-   Linux distribution or Windows OS version [compatible with New Relic's infrastructure agent](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/getting-started/compatibility-requirements-new-relic-infrastructure).

## Quick start [#quick]

Instrument your Nagios instance quickly and send your telemetry data with guided install. Our guided install creates a customized CLI command for your environment that downloads and installs the New Relic CLI and the infrastructure agent.

Ready to get started? Click one of these buttons to try it out.

[Guided install](https://one.newrelic.com/marketplace/install-data-source?state=d161ac12-7cf0-7fd2-9e34-0960a71e9ccd)

[EU Guided install](https://one.eu.newrelic.com/marketplace/install-data-source?state=d161ac12-7cf0-7fd2-9e34-0960a71e9ccd)

[JP Guided install](https://onenr.io/07wkJ6D6oQL)

## Install and activate [#install]

To install the Nagios integration:

**Linux installation**

1.  Install [the infrastructure agent](https://docs.newrelic.com/docs/integrations/host-integrations/installation/install-infrastructure-host-integrations/#install), and replace the `INTEGRATION_FILE_NAME` variable with `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](#config).

**Windows installation**

1.  Download the `nri-nagios` .MSI installer image from:

    <https://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:

    ```
    copy nagios-config.yml.sample nagios-config.yml
    ```
4.  Edit the `nagios-config.yml` file as described in the [configuration settings](#config).
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](#example-service-checks-yml).

Additional notes:

-   **Advanced:** It's also possible to [install the integration from a tarball file](https://docs.newrelic.com/docs/integrations/host-integrations/installation/install-host-integrations-built-new-relic#tarball). This gives you full control over the installation and configuration process.
-   **On-host integrations do not automatically update.** For best results, regularly [update the integration package](https://docs.newrelic.com/docs/integrations/host-integrations/installation/update-infrastructure-host-integration-package) and [the infrastructure agent](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/installation/update-infrastructure-agent).

## Configure the integration [#config]

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 example configurations, see the [nagios-config.yml and nagios-service-checks.yml examples](#example-config).

Our configuration files have common settings used in all of our integrations, such as `interval`, `timeout`, and`inventory_source`, among others. For more on these common settings, see this [list of configuration properties](https://docs.newrelic.com/docs/create-integrations/infrastructure-integrations-sdk/specifications/host-integrations-newer-configuration-format/#options-list).

Specific settings related to Nagios are defined using the `env` section of the configuration file. These settings control the connection to your Nagios instance as well as other security settings and features.

## Nagios instance settings [#instance-settings]

| Setting                   | Description                                                                                                                                        | Default                  |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| **SERVICE_CHECKS_CONFIG** | This points to a [yaml file](#service-checks-yaml) containing definitions of the service checks that will be run by the integration. **Required.** | N/A                      |
| **CONCURRENCY**           | The number of service checks to be run concurrently.                                                                                               | 1                        |
| **OUTPUT_TABLE_NAME**     | The name of the table where the service check results are saved.                                                                                   | NagiosServiceCheckSample |

## Service checks config file [#service-checks-yaml]

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 our 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 New Relic.                                                                                                     |
| `parse_output` | Attempts to parse the output of service checks that conform to the [Nagios Plugin API spec](https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/pluginapi.html). Default: `false`. |

These setting values can be defined in several ways:

-   Add the values directly in the config file.
-   Replace the values from environment variables using the `{{}}` notation. This requires infrastructure agent version 1.14.0 or higher. Read more [here](https://docs.newrelic.com/docs/infrastructure/install-infrastructure-agent/configuration/configure-infrastructure-agent/#passthrough).
-   Use secrets management to protect sensible information, such as passwords, so that it's not exposed in plain text in the configuration file. For more information, see [secrets management](https://docs.newrelic.com/docs/integrations/host-integrations/installation/secrets-management).

### Labels/custom attributes [#labels]

Environment variables can be used to control configuration settings, such as your license key, and are then passed to the infrastructure agent. For instructions on how to use the passthrough feature, see [Configure the infrastructure agent](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/configuration/configure-infrastructure-agent#passthrough).

You can also decorate your metrics using labels. Labels allow you to add key/value pair attributes to your metrics. You can use these labels to query, filter, or group your metrics.

Our default sample config file includes examples with labels, you can remove, modify, or add new ones of your choice.

```
 labels:
   env: production
   role: nagios
```

### 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](#config-parsing-failed) 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 configurations [#example-config]

Example file configurations:

**Example `nagios-config.yml` configuration**

````
integrations:
  - name: nri-nagios
    env:
      CONCURRENCY: "1"
      SERVICE_CHECKS_CONFIG: /etc/newrelic-infra/integrations.d/nagios-service-checks.yml
    interval: 15s
```

````

**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](https://docs.newrelic.com/docs/integrations/integrations-sdk/file-specifications/host-integration-configuration-overview).

## Find and use data [#find-and-use]

To find your integration data go to **[one.newrelic.com > All capabilities](https://one.newrelic.com/all-capabilities) > Infrastructure > Third-party services** and select one of the Nagios integration links.

Nagios data is attached to the `NagiosServiceCheckSample` [event type](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/glossary#event).

For more on how to find and use your data, see [Understand integration data](https://docs.newrelic.com/docs/infrastructure/integrations/find-use-infrastructure-integration-data).

## Metric data [#metrics]

The Nagios integration collects the following metric data attributes.

### Nagios service check sample metrics [#nagios-service-check-sample]

These attributes can be found by querying the `NagiosServiceCheckSample` event type.

| 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](https://nagios-plugins.org/doc/guidelines.html#AEN78) 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](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/troubleshooting/generate-logs-troubleshooting-infrastructure):

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

````

## Check the source code [#source-code]

This integration is open source software. That means you can [browse its source code](https://github.com/newrelic/nri-nagios) and send improvements, or create your own fork and build it.
