diff options
Diffstat (limited to 'plugins/utils.c')
-rw-r--r-- | plugins/utils.c | 39 |
1 files changed, 39 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; +} |