summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/utils.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 58b153d8..7f49e7be 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -630,3 +630,43 @@ char *fperfdata (const char *label,
630 630
631 return data; 631 return data;
632} 632}
633
634char *sperfdata (const char *label,
635 double val,
636 const char *uom,
637 char *warn,
638 char *crit,
639 int minp,
640 double minv,
641 int maxp,
642 double maxv)
643{
644 char *data = NULL;
645 if (strpbrk (label, "'= "))
646 xasprintf (&data, "'%s'=", label);
647 else
648 xasprintf (&data, "%s=", label);
649
650 xasprintf (&data, "%s%f", data, val);
651 xasprintf (&data, "%s%s;", data, uom);
652
653 if (warn!=NULL)
654 xasprintf (&data, "%s%s", data, warn);
655
656 xasprintf (&data, "%s;", data);
657
658 if (crit!=NULL)
659 xasprintf (&data, "%s%s", data, crit);
660
661 xasprintf (&data, "%s;", data);
662
663 if (minp)
664 xasprintf (&data, "%s%f", data, minv);
665
666 if (maxp) {
667 xasprintf (&data, "%s;", data);
668 xasprintf (&data, "%s%f", data, maxv);
669 }
670
671 return data;
672}