diff options
| author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2004-02-20 05:21:21 +0000 |
|---|---|---|
| committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2004-02-20 05:21:21 +0000 |
| commit | 7ba54264fb8b614f0ea0bc9eab5c974e2dca7cd8 (patch) | |
| tree | 78785a8fc62d7b89937efa9b5c23d007be7cee43 /plugins | |
| parent | 01a27016b794c8f779231bdf9ca48b371a4c7c85 (diff) | |
| download | monitoring-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')
| -rw-r--r-- | plugins/utils.c | 39 | ||||
| -rw-r--r-- | plugins/utils.h | 12 |
2 files changed, 51 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 | |||
| 549 | char *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 | } | ||
diff --git a/plugins/utils.h b/plugins/utils.h index c2b06415..35e62ab4 100644 --- a/plugins/utils.h +++ b/plugins/utils.h | |||
| @@ -92,6 +92,18 @@ char *perfdata (const char *label, | |||
| 92 | int maxp, | 92 | int maxp, |
| 93 | long int maxv); | 93 | long int maxv); |
| 94 | 94 | ||
| 95 | char *fperfdata (const char *label, | ||
| 96 | double val, | ||
| 97 | const char *uom, | ||
| 98 | int warnp, | ||
| 99 | double warn, | ||
| 100 | int critp, | ||
| 101 | double crit, | ||
| 102 | int minp, | ||
| 103 | double minv, | ||
| 104 | int maxp, | ||
| 105 | double maxv); | ||
| 106 | |||
| 95 | /* The idea here is that, although not every plugin will use all of these, | 107 | /* The idea here is that, although not every plugin will use all of these, |
| 96 | most will or should. Therefore, for consistency, these very common | 108 | most will or should. Therefore, for consistency, these very common |
| 97 | options should have only these meanings throughout the overall suite */ | 109 | options should have only these meanings throughout the overall suite */ |
