diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-26 10:44:14 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-26 10:44:14 +0000 |
commit | 68e8cc5f4dde114f706e28130b6c0f2779706a01 (patch) | |
tree | b49a0330a9700e344c3df5542b52e2f1ad6c3fbd /plugins/utils.c | |
parent | 1db3424e5f6b0b8cfbf41a287fe48296931be72b (diff) | |
download | monitoring-plugins-68e8cc5f4dde114f706e28130b6c0f2779706a01.tar.gz |
function to make perfdata output
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@696 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r-- | plugins/utils.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c index 5c809ece..aad30068 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -497,3 +497,47 @@ strpcat (char *dest, const char *src, const char *str) 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; +} |