Nagios / DNS Check Integration Guide


This page shows how to integrate Nagios with DNS Check, so that Nagios can take advantage of DNS Check's DNS record monitoring capabilities. This is accomplished through a combination of a Nagios plugin, and the DNS Check API.

Nagios provides software that's designed monitor your entire IT infrastructure. Nagios is particularly flexible because its functionality can be extended via easy to write plugins.

DNS Check provides an advanced DNS record monitoring service which allows you to monitor sets of DNS records for errors. DNS Check enables you to do things which most other DNS record monitoring tools don't, like check MX and SPF records, require that a DNS record be the only record of its name / record type combination, and import entire zone files for monitoring.

DNS Check supports monitoring the following DNS record types:

Monitoring Options

There are two approaches you can take to monitoring DNS records:

  1. Monitor individual DNS records
  2. Monitor DNS record groups

In most cases, we recommend monitoring DNS record groups, since that allows you to logically group your DNS records in a way which usually simplifies the Nagios configuration. For example, you could create a single DNS record group that monitors all DNS records that relate to your mail servers. Check out the DNS Record Groups document for more details on what DNS record groups are, and how to work with them.

DNS Check Configuration

Let's get started by configuring DNS record monitoring within DNS Check:

  1. Create a DNS record group, then import the DNS records that you'd like to monitor. The Monitor DNS Records document describes how to do this.
  2. Generate a DNS Check API key. We'll use this API key later when we configure Nagios.

Nagios Plugin Selection

DNS Check's API returns JSON formatted data, so we'll need a Nagios plugin that can make an API request, parse the JSON, and extract the pass / fail status before returning it to Nagios. We're going to use the check_http_json Nagios plugin to accomplish this.

Nagios Configuration

We completed the following steps on a CentOS 7 server with the nagios-3.5.1 package installed from EPEL. Some details, like filesystem paths may differ if you're using a different Nagios package:

  1. Save the check_http_json.rb file to your Nagios plugins directory. On our Nagios server this was /usr/lib64/nagios/plugins/.
  2. Make the check_http_json.rb file executable. For example:
    chmod 755 /usr/lib64/nagios/plugins/check_http_json.rb
  3. Test the plugin to verify that all of its dependencies are installed:
    /usr/lib64/nagios/plugins/check_http_json.rb -u '' -e 'dns_record.status' -r 'pass' -W 'unknown'
  4. Add the check_dns_record_group and check_dns_record commands to Nagios. For example, I placed the following in /etc/nagios/objects/commands.cfg:
    define command {
        command_name    check_dns_record_group
        command_line    $USER1$/check_http_json.rb -u '$ARG1$?api_key=YOUR_API_KEY' -e 'group.status' -r 'pass' -W 'unknown' -C 'fail'
    define command {
        command_name    check_dns_record
        command_line    $USER1$/check_http_json.rb -u '$ARG1$/$ARG2$?api_key=YOUR_API_KEY' -e 'dns_record.status' -r 'pass' -W 'unknown' -C 'fail'

    Replace instances of "YOUR_API_KEY" in the above command definitions with the DNS Check API key that you generated earlier.

  5. Add one or more services to Nagios' configuration:
    • Here's an example of a how to check an entire DNS record group. This is the recommended approach:
      define service {
          name                    mail-server-dns-records
          service_description     Mail Server DNS Records
          use                     generic-service
          check_command           check_dns_record_group!YOUR_DNS_RECORD_GROUP
    • Here's an example of a how to check an individual DNS record:
      define service {
          name                    mx-record
          service_description     MX Record
          use                     generic-service
          check_command           check_dns_record!YOUR_DNS_RECORD_GROUP!YOUR_DNS_RECORD

    If you copy/paste either of the above examples into Nagios, then you'll need to make the following updates:

    1. Set the "name", "service_description", "use", and "host_name" values to the desired values. These are standard Nagios configuration parameters documented by Nagios here.
    2. Replace "YOUR_DNS_RECORD_GROUP" with the UUID of the DNS record group to check. This is the 36-character string that follows "/tests/" in the DNS record group URL. For example, this DNS record group's UUID is "ea883d67-d9f6-45e3-b3a1-844dd1857824".
    3. If you're testing a DNS record, replace "YOUR_DNS_RECORD" with the ID of the DNS record to check. This is the number that follows the UUID in the DNS record's URL. For example, This DNS record has an ID of "1". This is not needed if you're testing a DNS record group.
  6. Test Nagios's configuration, and apply the changes. For example:
    nagios -v /etc/nagios/nagios.cfg && /etc/init.d/nagios reload

Sign Up For a Free Account

Free accounts can check up to 10 DNS records at a time. You can always upgrade to a paid account later.