From 27d96dcf23c44c74d0a2be7ea94f47798e37030a Mon Sep 17 00:00:00 2001 From: rincewind Date: Fri, 9 Jul 2021 16:07:23 +0200 Subject: Do not show RTA if no connection was possible diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 423ecbe..7d58b10 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c @@ -37,6 +37,8 @@ const char *email = "devel@monitoring-plugins.org"; #include "popen.h" #include "utils.h" +#include + #define WARN_DUPLICATES "DUPLICATES FOUND! " #define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */ @@ -163,10 +165,14 @@ main (int argc, char **argv) printf (""); /* Print performance data */ - printf("|%s", fperfdata ("rta", (double) rta, "ms", - wrta>0?TRUE:FALSE, wrta, - crta>0?TRUE:FALSE, crta, - TRUE, 0, FALSE, 0)); + if (pl != 100) { + printf("|%s", fperfdata ("rta", (double) rta, "ms", + wrta>0?TRUE:FALSE, wrta, + crta>0?TRUE:FALSE, crta, + TRUE, 0, FALSE, 0)); + } else { + printf("|"); + } printf(" %s\n", perfdata ("pl", (long) pl, "%", wpl>0?TRUE:FALSE, wpl, cpl>0?TRUE:FALSE, cpl, -- cgit v0.10-9-g596f From 0214ec1918abf589f15b70948ddba641a9729ce3 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 17 Nov 2021 14:09:11 +0100 Subject: Show RTA as unknown if it can not be determined diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 7d58b10..6aa43ed 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c @@ -171,7 +171,7 @@ main (int argc, char **argv) crta>0?TRUE:FALSE, crta, TRUE, 0, FALSE, 0)); } else { - printf("|"); + printf("| rta=U;;;;;"); } printf(" %s\n", perfdata ("pl", (long) pl, "%", wpl>0?TRUE:FALSE, wpl, -- cgit v0.10-9-g596f From 1c53c4f541db3afdc3a2975121b69064d53f7ef3 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 17 Nov 2021 15:45:17 +0100 Subject: homogenize perfdata function and fix small bug with missing semicolon diff --git a/plugins/utils.c b/plugins/utils.c index ebdae2e..17dd581 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -589,10 +589,12 @@ char *perfdata (const char *label, xasprintf (&data, "%s;", data); if (minp) - xasprintf (&data, "%s%ld", data, minv); + xasprintf (&data, "%s%ld;", data, minv); + else + xasprintf (&data, "%s;", data); if (maxp) - xasprintf (&data, "%s;%ld", data, maxv); + xasprintf (&data, "%s%ld", data, maxv); return data; } -- cgit v0.10-9-g596f From e030c2d17c10446bda840d66f6753b9bf573d715 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 17 Nov 2021 15:45:49 +0100 Subject: Add thresholds even if value is missing diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 6aa43ed..ba7af37 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c @@ -171,7 +171,7 @@ main (int argc, char **argv) crta>0?TRUE:FALSE, crta, TRUE, 0, FALSE, 0)); } else { - printf("| rta=U;;;;;"); + printf("| rta=U;%f;%f;;", wrta, crta); } printf(" %s\n", perfdata ("pl", (long) pl, "%", wpl>0?TRUE:FALSE, wpl, -- cgit v0.10-9-g596f