From 0488426c7e8018d77734fb0e46328182de28f76a Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Wed, 28 Feb 2024 15:37:27 +0100 Subject: check_icmp: keep performance data order in case of none-reachable hosts For responding hosts nothing changes: ./check_icmp -H 10.0.0.1 OK - 10.0.0.1 rta 0.336ms lost 0%|rta=0.336ms;200.000;500.000;0; rtmax=0.471ms;;;; rtmin=0.000ms;;;; pl=0%;40;80;0;100 In case the host is down, the performance data now contain 'U' according to: https://www.monitoring-plugins.org/doc/guidelines.html#AEN201 Old: ./check_icmp -H 10.0.0.99 CRITICAL - 10.0.0.99: Host unreachable @ 10.0.1.138. rta nan, lost 100%|pl=100%;40;80;0;100 Old: ./check_icmp -H 10.0.0.99 CRITICAL - 10.0.0.99: Host unreachable @ 10.0.1.138. rta nan, lost 100%|rta=U;;;; rtmax=U;;;; rtmin=U;;;; pl=100%;40;80;0;100 This confuses some performance graphing tools, ex.: pnp. Signed-off-by: Sven Nierlein --- plugins-root/t/check_icmp.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins-root/t') diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t index 4f9db868..de1d88d2 100644 --- a/plugins-root/t/check_icmp.t +++ b/plugins-root/t/check_icmp.t @@ -12,7 +12,7 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO", "no" ); if ($allow_sudo eq "yes" or $> == 0) { - plan tests => 39; + plan tests => 40; } else { plan skip_all => "Need sudo to test check_icmp"; } @@ -57,7 +57,8 @@ $res = NPTest->testCmd( "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -t 2" ); is( $res->return_code, 2, "Timeout - host nonresponsive" ); -like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" ); +like( $res->output, '/pl=100%/', "Error contains 'pl=100%' string (for 100% packet loss)" ); +like( $res->output, '/rta=U/', "Error contains 'rta=U' string" ); $res = NPTest->testCmd( "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%" -- cgit v1.2.3-74-g34f1