summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2004-02-20 05:21:21 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2004-02-20 05:21:21 (GMT)
commit7ba54264fb8b614f0ea0bc9eab5c974e2dca7cd8 (patch)
tree78785a8fc62d7b89937efa9b5c23d007be7cee43 /plugins/utils.c
parent01a27016b794c8f779231bdf9ca48b371a4c7c85 (diff)
downloadmonitoring-plugins-7ba54264fb8b614f0ea0bc9eab5c974e2dca7cd8.tar.gz
add perfdata function for floats to complement ints, also spell fix "received"
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@817 f882894a-f735-0410-b71e-b25c423dba1c
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 ec25473..77e2e27 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}