3 # Simple Nagios-compatible checker for NSD zone status.
5 # SPDX-License-Identifier: GPL-3.0-or-later
6 # Copyright (C) 2021-2024 Simon Ruderich
13 use Monitoring::Plugin;
16 my $np = Monitoring::Plugin->new;
19 open my $fh, '-|', '/usr/sbin/nsd-control', 'zonestatus';
21 if (/^zone:\s+(.+)$/) {
25 if (/^\s+state: (.+)$/) {
26 unless (defined $zone) {
27 $np->add_message(CRITICAL, "cannot parse `nsd-control` output");
31 if ($1 eq 'ok' or $1 eq 'master') {
33 } elsif ($1 eq 'refreshing') {
34 $np->add_message(WARNING, "$zone: status $1");
36 $np->add_message(CRITICAL, "$zone: status $1");
43 $np->plugin_exit($np->check_messages);