aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorGravatar Gerhard Lausser <gerhard.lausser@consol.de> 2015-04-19 01:12:44 +0200
committerGravatar Sven Nierlein <sven@nierlein.de> 2015-04-21 19:11:56 +0200
commit81be2afd957c2c5d50bdf37301e0af679fedb8e9 (patch)
treec5b734e51b1806de051b41575c426ddc4272b7e6 /plugins/utils.c
parent500f8aec81c3a378e22c6ec767cf6d8fbc9f77b4 (diff)
downloadmonitoring-plugins-81be2afd957c2c5d50bdf37301e0af679fedb8e9.tar.gz
add sperfdata function which can handle threshold ranges
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 58b153d8..7f49e7be 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -630,3 +630,43 @@ char *fperfdata (const char *label,
return data;
}
+
+char *sperfdata (const char *label,
+ double val,
+ const char *uom,
+ char *warn,
+ char *crit,
+ int minp,
+ double minv,
+ int maxp,
+ double maxv)
+{
+ char *data = NULL;
+ if (strpbrk (label, "'= "))
+ xasprintf (&data, "'%s'=", label);
+ else
+ xasprintf (&data, "%s=", label);
+
+ xasprintf (&data, "%s%f", 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%f", data, minv);
+
+ if (maxp) {
+ xasprintf (&data, "%s;", data);
+ xasprintf (&data, "%s%f", data, maxv);
+ }
+
+ return data;
+}