summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c39
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,
544 544
545 return data; 545 return data;
546} 546}
547
548
549char *fperfdata (const char *label,
550 double val,
551 const char *uom,
552 int warnp,
553 double warn,
554 int critp,
555 double crit,
556 int minp,
557 double minv,
558 int maxp,
559 double maxv)
560{
561 char *data = NULL;
562
563 if (strpbrk (label, "'= "))
564 asprintf (&data, "'%s'=%ld%s;", label, val, uom);
565 else
566 asprintf (&data, "%s=%ld%s;", label, val, uom);
567
568 if (warnp)
569 asprintf (&data, "%s%ld;", data, warn);
570 else
571 asprintf (&data, "%s;", data);
572
573 if (critp)
574 asprintf (&data, "%s%ld;", data, crit);
575 else
576 asprintf (&data, "%s;", data);
577
578 if (minp)
579 asprintf (&data, "%s%ld", data, minv);
580
581 if (maxp)
582 asprintf (&data, "%s;%ld", data, maxv);
583
584 return data;
585}