summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 58b153d..a864e4a 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -144,8 +144,6 @@ usage5 (void)
144void 144void
145print_revision (const char *command_name, const char *revision) 145print_revision (const char *command_name, const char *revision)
146{ 146{
147 char plugin_revision[STRLEN];
148
149 printf ("%s v%s (%s %s)\n", 147 printf ("%s v%s (%s %s)\n",
150 command_name, revision, PACKAGE, VERSION); 148 command_name, revision, PACKAGE, VERSION);
151} 149}
@@ -630,3 +628,43 @@ char *fperfdata (const char *label,
630 628
631 return data; 629 return data;
632} 630}
631
632char *sperfdata (const char *label,
633 double val,
634 const char *uom,
635 char *warn,
636 char *crit,
637 int minp,
638 double minv,
639 int maxp,
640 double maxv)
641{
642 char *data = NULL;
643 if (strpbrk (label, "'= "))
644 xasprintf (&data, "'%s'=", label);
645 else
646 xasprintf (&data, "%s=", label);
647
648 xasprintf (&data, "%s%f", data, val);
649 xasprintf (&data, "%s%s;", data, uom);
650
651 if (warn!=NULL)
652 xasprintf (&data, "%s%s", data, warn);
653
654 xasprintf (&data, "%s;", data);
655
656 if (crit!=NULL)
657 xasprintf (&data, "%s%s", data, crit);
658
659 xasprintf (&data, "%s;", data);
660
661 if (minp)
662 xasprintf (&data, "%s%f", data, minv);
663
664 if (maxp) {
665 xasprintf (&data, "%s;", data);
666 xasprintf (&data, "%s%f", data, maxv);
667 }
668
669 return data;
670}