From a5983eda69b442a90495909803724901669b50fb Mon Sep 17 00:00:00 2001 From: "John C. Frickson" Date: Mon, 7 Nov 2016 13:06:05 -0600 Subject: check_users not correctly detecting thresholds Fix for issue https://github.com/nagios-plugins/nagios-plugins/issues/81 check_users now uses the standard warning and critical ranges parser and a standard perdata output routine. --- plugins/utils.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'plugins/utils.c') diff --git a/plugins/utils.c b/plugins/utils.c index a864e4aa..231af92b 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -668,3 +668,44 @@ char *sperfdata (const char *label, return data; } + +char *sperfdata_int (const char *label, + int val, + const char *uom, + char *warn, + char *crit, + int minp, + int minv, + int maxp, + int maxv) +{ + char *data = NULL; + if (strpbrk (label, "'= ")) + xasprintf (&data, "'%s'=", label); + else + xasprintf (&data, "%s=", label); + + xasprintf (&data, "%s%d", data, val); + xasprintf (&data, "%s%s;", data, uom); + + if (warn!=NULL) + xasprintf (&data, "%s%s", data, warn); + + xasprintf (&data, "%s;", data); + + if (crit!=NULL) + xasprintf (&data, "%s%s", data, crit); + + xasprintf (&data, "%s;", data); + + if (minp) + xasprintf (&data, "%s%d", data, minv); + + if (maxp) { + xasprintf (&data, "%s;", data); + xasprintf (&data, "%s%d", data, maxv); + } + + return data; +} + -- cgit v1.2.3