licensed under GPLv3+ except where otherwise noted.
:bird: https://bird.network.cz/
+:nsd: https://www.nlnetlabs.nl/projects/nsd/about/
- icinga/check_bird: Connect to {bird}[BIRD] and check if a given list of
protocols is running.
+- check_nsd_zonestatus: Connect to {nsd}[NSD] and check if all zones are find
+ (and e.g. not "refreshing").
--- /dev/null
+#!/usr/bin/perl
+
+# Simple Nagios-compatible checker for NSD zone status.
+
+# SPDX-License-Identifier: GPL-3.0-or-later
+# Copyright (C) 2021-2024 Simon Ruderich
+
+
+use strict;
+use warnings;
+use autodie;
+
+use Monitoring::Plugin;
+
+
+my $np = Monitoring::Plugin->new;
+
+my $zone;
+open my $fh, '-|', '/usr/sbin/nsd-control', 'zonestatus';
+while (<$fh>) {
+ if (/^zone:\s+(.+)$/) {
+ $zone = $1;
+ next;
+ }
+ if (/^\s+state: (.+)$/) {
+ unless (defined $zone) {
+ $np->add_message(CRITICAL, "cannot parse `nsd-control` output");
+ next;
+ }
+
+ if ($1 eq 'ok' or $1 eq 'master') {
+ # This is fine
+ } elsif ($1 eq 'refreshing') {
+ $np->add_message(WARNING, "$zone: status $1");
+ } else {
+ $np->add_message(CRITICAL, "$zone: status $1");
+ }
+ $zone = undef;
+ }
+}
+close $fh;
+
+$np->plugin_exit($np->check_messages);