aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorGravatar John C. Frickson <jfrickson@nagios.com> 2016-11-07 13:06:05 -0600
committerGravatar Sven Nierlein <sven@nierlein.de> 2016-11-07 21:36:25 +0100
commita5983eda69b442a90495909803724901669b50fb (patch)
treefa3442fe3bc20309245188d88d77c6cdd15c17d9 /plugins/utils.c
parent3a12034805caf6c4ad21a8f86c8e4a43ff62576c (diff)
downloadmonitoring-plugins-a5983eda69b442a90495909803724901669b50fb.tar.gz
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.
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c41
1 files changed, 41 insertions, 0 deletions
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;
+}
+