Monitoring

Nagios / Icinga Integration

Overview

The check_seconddns.sh plugin queries the SecondDNS health API and returns standard Nagios exit codes (0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN) with perfdata.

Prerequisites

  • Nagios, Icinga, or compatible monitoring system
  • curl installed on the monitoring server
  • A SecondDNS API key (Dashboard → API Key)

1. Download the plugin

curl -o /usr/lib/nagios/plugins/check_seconddns.sh \
  https://raw.githubusercontent.com/seconddns/dns_integrations/main/nagios_plugins/check_seconddns.sh

chmod +x /usr/lib/nagios/plugins/check_seconddns.sh

Source: github.com/seconddns/dns_integrations/nagios_plugins

2. Define the command

Add to your Nagios commands config (e.g. /etc/nagios/objects/commands.cfg):

define command {
    command_name    check_seconddns
    command_line    /usr/lib/nagios/plugins/check_seconddns.sh -k $ARG1$ $ARG2$
}

3. Define the service

Check all zones at once:

define service {
    host_name               your-dns-host
    service_description     SecondDNS Zone Health
    check_command           check_seconddns!your-api-key-here!
    check_interval          15
    retry_interval          5
    max_check_attempts      3
    notification_interval   60
}

Or check a single zone:

define service {
    host_name               your-dns-host
    service_description     SecondDNS: example.com
    check_command           check_seconddns!your-api-key-here!-z example.com
    check_interval          15
    ...
}

4. Output examples

# All zones healthy:
OK - all 12 zones synced

# Problems detected:
WARNING - example.com stale 135min master=2024041503 ours=2024041501 | stale_min=135;120;360
CRITICAL - broken.net master_unreachable since 2026-04-16T13:00:00Z | stale_min=390;120;360

How it works

  1. Plugin calls GET /api/health/zones?format=nagios (or /api/health/zones/ZONE?format=nagios)
  2. API returns plain text — one line per problem zone, or "OK" if all synced
  3. Plugin parses the first word (OK/WARNING/CRITICAL) and sets the exit code
  4. Nagios picks up the exit code and perfdata for alerting and graphs