diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2021-11-18 10:00:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 10:00:12 +0100 |
commit | d6d2254312aede137dcd998a4cdfa26ecd07e379 (patch) | |
tree | 2fc0272f526bb6c53ccf1888764f749acfbd7ee4 | |
parent | 4549a9524349c4384c0a7a2ca8662a418fc8fbe5 (diff) | |
parent | e030c2d17c10446bda840d66f6753b9bf573d715 (diff) | |
download | monitoring-plugins-d6d2254312aede137dcd998a4cdfa26ecd07e379.tar.gz |
Merge pull request #1697 from RincewindsHat/dont_show_rta_if_useless
check_ping: Do not show RTA if no connection was possible
-rw-r--r-- | plugins/check_ping.c | 14 | ||||
-rw-r--r-- | plugins/utils.c | 6 |
2 files changed, 14 insertions, 6 deletions
diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 423ecbe5..ba7af373 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 <signal.h> + #define WARN_DUPLICATES "DUPLICATES FOUND! " #define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */ @@ -163,10 +165,14 @@ main (int argc, char **argv) printf ("</A>"); /* 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("| rta=U;%f;%f;;", wrta, crta); + } printf(" %s\n", perfdata ("pl", (long) pl, "%", wpl>0?TRUE:FALSE, wpl, cpl>0?TRUE:FALSE, cpl, diff --git a/plugins/utils.c b/plugins/utils.c index ebdae2e1..17dd5814 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; } |