summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c83
1 files changed, 81 insertions, 2 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 58b153d..231af92 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,84 @@ 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}
671
672char *sperfdata_int (const char *label,
673 int val,
674 const char *uom,
675 char *warn,
676 char *crit,
677 int minp,
678 int minv,
679 int maxp,
680 int maxv)
681{
682 char *data = NULL;
683 if (strpbrk (label, "'= "))
684 xasprintf (&data, "'%s'=", label);
685 else
686 xasprintf (&data, "%s=", label);
687
688 xasprintf (&data, "%s%d", data, val);
689 xasprintf (&data, "%s%s;", data, uom);
690
691 if (warn!=NULL)
692 xasprintf (&data, "%s%s", data, warn);
693
694 xasprintf (&data, "%s;", data);
695
696 if (crit!=NULL)
697 xasprintf (&data, "%s%s", data, crit);
698
699 xasprintf (&data, "%s;", data);
700
701 if (minp)
702 xasprintf (&data, "%s%d", data, minv);
703
704 if (maxp) {
705 xasprintf (&data, "%s;", data);
706 xasprintf (&data, "%s%d", data, maxv);
707 }
708
709 return data;
710}
711