From 29fc33a8e75f2fd7c6fdeaf39ce0db1b4d23040a Mon Sep 17 00:00:00 2001 From: Chl Date: Mon, 2 Oct 2023 15:54:59 +0200 Subject: [PATCH] check_bind9.pl: sort perfdata keys --- nagios/check_bind9.pl | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/nagios/check_bind9.pl b/nagios/check_bind9.pl index c2ea5a9..59f841a 100755 --- a/nagios/check_bind9.pl +++ b/nagios/check_bind9.pl @@ -208,7 +208,8 @@ my @STATUS_KEYS = qw( tcp_hard_limit ); -my @PERFKEYS = ( @STATS_KEYS, @STATUS_KEYS, ); +my @TMP = ( @STATS_KEYS, @STATUS_KEYS, ); +my @PERFKEYS = sort @TMP; my %PERFDATA = map { ( $_ => 0, ) } @PERFKEYS; sub slurp_command { @@ -339,7 +340,7 @@ for my $status_line ( slurp_command(@RNDC_STATUS) ) { $PERFDATA{'zones'} = $1; } elsif ( $status_line =~ m/debug level: (\d+)/i ) { - $PERFDATA{'debug'} = $1; + $PERFDATA{'debug'} = $1 . q{;1}; } elsif ( $status_line =~ m/xfers running: (\d+)/i ) { $PERFDATA{'xfers_running'} = $1; @@ -405,30 +406,28 @@ print qq{ |}; # http://docs.pnp4nagios.org/pnp-0.6/perfdata_format # Stats keys are all 'Counter' data -for my $k (@STATS_KEYS) { - print q{ } , $k , q{=} , $PERFDATA{$k} , q{c}; -} -my %EXTRAS = ( - q{debug} => ';1', # Warning if in debug -); +#for my $k (@STATS_KEYS) { +# print q{ } , $k , q{=} , $PERFDATA{$k} , q{c}; +#} if ( $PERFDATA{'udp_soft_limit'} + $PERFDATA{'udp_hard_limit'} > 0 ) { - # Running at soft limit is warning, running at hard limit is critical - - $EXTRAS{'udp_running'} = q{;} + $PERFDATA{'udp_running'} .= q{;} . ( $PERFDATA{'udp_soft_limit'} || q{} ) . q{;} . ( $PERFDATA{'udp_hard_limit'} || q{} ); } if ( $PERFDATA{'tcp_hard_limit'} ) { - # Running at hard limit is critical - $EXTRAS{'tcp_running'} = q{;;} . $PERFDATA{'tcp_hard_limit'}; + $PERFDATA{'tcp_running'} .= q{;;} . $PERFDATA{'tcp_hard_limit'}; } -for my $k (@STATUS_KEYS) { - print q{ } , $k , q{=} , $PERFDATA{$k}; - if ( defined $EXTRAS{$k} ) { - print $EXTRAS{$k}; +for my $k (@PERFKEYS) { + if ( defined $PERFDATA{$k} ) { + print q{ } , $k , q{=} , $PERFDATA{$k}; + if (grep( /^$k$/, @STATS_KEYS )) { + print q{c}; + } + #if ( defined $EXTRAS{$k} ) { + # print $EXTRAS{$k}; } } exit $exit_code;