[monitoring-plugins] add sperfdata function which can handle threshold ...
Sven Nierlein
git at monitoring-plugins.org
Tue Apr 21 19:40:11 CEST 2015
Module: monitoring-plugins
Branch: test_1335
Commit: 81be2afd957c2c5d50bdf37301e0af679fedb8e9
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Committer: Sven Nierlein <sven at nierlein.de>
Date: Sun Apr 19 01:12:44 2015 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=81be2af
add sperfdata function which can handle threshold ranges
---
plugins/utils.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/plugins/utils.c b/plugins/utils.c
index 58b153d..7f49e7b 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;
+}
More information about the Commits
mailing list