summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1db3424)
raw | patch | inline | side by side (parent: 1db3424)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Tue, 26 Aug 2003 10:44:14 +0000 (10:44 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Tue, 26 Aug 2003 10:44:14 +0000 (10:44 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@696 f882894a-f735-0410-b71e-b25c423dba1c
plugins/utils.c | patch | blob | history | |
plugins/utils.h | patch | blob | history |
diff --git a/plugins/utils.c b/plugins/utils.c
index 5c809ece48fc2832061f45fb6f2c3478c4feeafc..aad300686a0f1f6c173302fa7911a91591bf3065 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
return dest;
}
+
+
+
+
+/******************************************************************************
+ *
+ * Print perfdata in a standard format
+ *
+ ******************************************************************************/
+
+char *perfdata (const char *label,
+ long int val,
+ const char *uom,
+ int warnp,
+ long int warn,
+ int critp,
+ long int crit,
+ int minp,
+ long int minv,
+ int maxp,
+ long int maxv)
+{
+ char *data = NULL;
+
+ 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 efdbed41d49f560c3e0c743cf31287f0b1d8ad3a..282f299eb3daa1ee716cf81776efe3f639fec75d 100644 (file)
--- a/plugins/utils.h
+++ b/plugins/utils.h
#define max(a,b) (((a)>(b))?(a):(b))
+char *perfdata (const char *label,
+ long int val,
+ const char *uom,
+ int warnp,
+ long int warn,
+ int critp,
+ long int crit,
+ int minp,
+ long int minv,
+ int maxp,
+ long int 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 */