From: Simon Ruderich Date: Wed, 10 Jan 2024 20:00:57 +0000 (+0100) Subject: icinga/check_nsd_zonestatus: add X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;ds=sidebyside;p=misc%2Fmisc.git icinga/check_nsd_zonestatus: add --- diff --git a/README.adoc b/README.adoc index dfb87b4..2f42365 100644 --- a/README.adoc +++ b/README.adoc @@ -4,6 +4,9 @@ Repository of miscellaneous tools which might be useful to others. They are 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"). diff --git a/icinga/check_nsd_zonestatus b/icinga/check_nsd_zonestatus new file mode 100755 index 0000000..a47783e --- /dev/null +++ b/icinga/check_nsd_zonestatus @@ -0,0 +1,43 @@ +#!/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);