aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2004-02-20 05:21:21 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2004-02-20 05:21:21 +0000
commit7ba54264fb8b614f0ea0bc9eab5c974e2dca7cd8 (patch)
tree78785a8fc62d7b89937efa9b5c23d007be7cee43
parent01a27016b794c8f779231bdf9ca48b371a4c7c85 (diff)
downloadmonitoring-plugins-7ba54264fb8b614f0ea0bc9eab5c974e2dca7cd8.tar.gz
add perfdata function for floats to complement ints, also spell fix "received"
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@817 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/utils.c39
-rw-r--r--plugins/utils.h12
2 files changed, 51 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index ec254739..77e2e279 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -544,3 +544,42 @@ char *perfdata (const char *label,
return data;
}
+
+
+char *fperfdata (const char *label,
+ double val,
+ const char *uom,
+ int warnp,
+ double warn,
+ int critp,
+ double crit,
+ int minp,
+ double minv,
+ int maxp,
+ double maxv)
+{
+ char *data = NULL;
+
+ if (strpbrk (label, "'= "))
+ asprintf (&data, "'%s'=%ld%s;", label, val, uom);
+ else
+ asprintf (&data, "%s=%ld%s;", label, val, uom);
+
+ if (warnp)
+ asprintf (&data, "%s%ld;", data, warn);
+ else
+ asprintf (&data, "%s;", data);
+
+ if (critp)
+ asprintf (&data, "%s%ld;", data, crit);
+ else
+ asprintf (&data, "%s;", data);
+
+ if (minp)
+ asprintf (&data, "%s%ld", data, minv);
+
+ if (maxp)
+ asprintf (&data, "%s;%ld", data, maxv);
+
+ return data;
+}
diff --git a/plugins/utils.h b/plugins/utils.h
index c2b06415..35e62ab4 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -92,6 +92,18 @@ char *perfdata (const char *label,
int maxp,
long int maxv);
+char *fperfdata (const char *label,
+ double val,
+ const char *uom,
+ int warnp,
+ double warn,
+ int critp,
+ double crit,
+ int minp,
+ double minv,
+ int maxp,
+ double maxv);
+
/* The idea here is that, although not every plugin will use all of these,
most will or should. Therefore, for consistency, these very common
options should have only these meanings throughout the overall suite */