Skip to main content

check_soa_serials is an Icinga2/Nagios plugin which compares the SOA serial numbers for the same DNS zone(s) from two different servers to ensure they are in sync

Project description

check_soa_serials

check_soa_serials is a Nagios/Icinga2 plugin that compares the SOA serial numbers for the same DNS zone(s) from two different servers to ensure they are in sync

Requires Python 3.6+

Installation

You can install with pip:

python3 -m pip install check_soa_serials

Or install from source:

git clone <url>
pip install check_soa_serials

Usage

usage: check_soa_serials [-h] [--proto {tcp,udp}] [--file ZONES_FROM_FILE] [--critical CRITICAL] [--warning WARNING] [--zone ZONES_FROM_ARGS] [--verbose] host host

The simplest case:

# Check that the SOA serial for the zone `myzone.domain.tld` is the same on
both `dnsserver1.domain.tld` and `dnsserver2.domain.tld.
# Alert critical if they are not the same.
check_soa_serials --zone myzone.domain.tld dnsserver1.domain.tld dnsserver2.domain.tld

The same as the preceding example, but WARNING instead of CRITICAL by altering the critical threshold to be impossible to match:

check_soa_serials --zone myzone.domain.tld --critical=~: dnsserver1.domain.tld dnsserver2.domain.tld

For more on Nagios plugin ranges, thresholds, perfdata, and return codes, see Nagios Plugin Development Guidelines.

Icinga2

Here is an Icinga2 CheckCommand object for this plugin:

object CheckCommand "soa_serials" {
  command = [ PluginDir + "/check_soa_serials", ]
  arguments = {
    "--critical" = {
      description = "Critical range for number of zones not in sync"
      key = "--critical"
      set_if = "$soa_serials_critical$"
      value = "$soa_serials_critical$"
    }
    "--warning" = {
      description = "Warning range for number of zones not in sync"
      key = "--warning"
      set_if = "$soa_serials_warning$"
      value = "$soa_serials_warning$"
    }
    "--proto" = {
      description = "Protocol to use for DNS queries"
      key = "--proto"
      set_if = "$soa_serials_proto$"
      value = "$soa_serials_proto$"
    }
    "--zones-file" = {
      description = "Protocol to use for DNS queries"
      key = "--zones-file"
      set_if = "$soa_serials_zones_file"
      value = "$soa_serials_zones_file"
    }
    "--zone" = {
      description = "A zone to compare the serials for between DNS hosts"
      key = "--zone"
      repeat_key = true
      set_if = "$soa_serials_zone"
      value = "$soa_serials_zone"
    }
    host1 = {
      description = "DNS host 1"
      required = true
      skip_key = true
      value = "$check_soa_serials_host1$"
    }
    host2 = {
      description = "DNS host 2"
      required = true
      skip_key = true
      value = "$check_soa_serials_host2$"
    }
  }
}

And a minimal example Icinga Service:

object Service "host.domain.tld_check" {
  import "generic-service"
  display_name = "SOA Zones in sync"
  host_name = "host.domain.tld"
  check_command = "check_soa_serials"
  notes = "The `check_soa_serials` command is a custom plugin that compares the SOA serial numbers for the same DNS zones from two different servers to ensure they are in sync."
  notes_url = "https://gitlab.com/theias/check_soa_serials"
  vars.host1 = "$address$"
  vars.host2 = "otherdns.domain.tld"
}

Note on the command path: the above Icinga2 configuration object points to the command in Icinga2's configured PluginDir, but this can be configured however you like. For instance:

  • point it to wherever it is installed by its full path
  • symlink from the specified path to the actual script.
  • or take the kludge route, leave it as-is, and copy __main__.py from this repo into PluginDir/

Up to you!

Limitations

DNSSEC is not supported, but it could be.

Contributing

Merge requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

To run the test suite:

# Dependent targets create venv and install dependencies
make

Please make sure to update tests along with any changes.

License

License :: OSI Approved :: MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

check_soa_serials-0.2.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

check_soa_serials-0.2.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file check_soa_serials-0.2.1.tar.gz.

File metadata

  • Download URL: check_soa_serials-0.2.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for check_soa_serials-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f7f1a593afdbc3502ae7a6d0123f4a0c4734c757cf3ba8e5502949c614479d47
MD5 76a0229579776f3787db1de19df7f2ff
BLAKE2b-256 acd505ea618a4a1d7fe67cbf4495b22ea60c68b2a04c2ad8eecb61b4e7274fb6

See more details on using hashes here.

File details

Details for the file check_soa_serials-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for check_soa_serials-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93b096870cc4b67b86c6206f4ae50ba08f1cfeaecc87fc403b62835cfd7cef5f
MD5 07ecea4e4ef3ee465c89f0a699fbfc03
BLAKE2b-256 dbafdf9b5c3d10bbee5e9c381a77086f5f1885eeabd8a54a75b234da983abe4c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page