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 "check_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.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: check_soa_serials-0.2.0.tar.gz
  • Upload date:
  • Size: 8.3 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.0.tar.gz
Algorithm Hash digest
SHA256 7c2b20a28f1b969e79310d0a45a8c4d8b136254783fa969eeb0af4f73793d762
MD5 8d1337ddca2afef9c47034316263c8f9
BLAKE2b-256 652da025115005a7162fe75876d701b300aa6e88e53daba40c5593533f99f147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for check_soa_serials-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 582a881933e5063ae9507a218db9bab95a8193f9901067b7c5420d38fee5c2dc
MD5 3175212cf7e7e0575c997be0c1af5e74
BLAKE2b-256 88f1010f051449b3212ea254ec41f968407afb5aa0f721d54e4f34d35b20c81a

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