1
0
Fork 0

check_bind9.pl: sort perfdata keys

This commit is contained in:
Chl 2023-10-02 15:54:59 +02:00
parent 76668f21b4
commit 29fc33a8e7

View file

@ -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;