diff options
Diffstat (limited to 'plugins/utils.c')
| -rw-r--r-- | plugins/utils.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/plugins/utils.c b/plugins/utils.c index 34335c89..dc6f5a85 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
| @@ -40,7 +40,6 @@ extern const char *progname; | |||
| 40 | #define STRLEN 64 | 40 | #define STRLEN 64 |
| 41 | #define TXTBLK 128 | 41 | #define TXTBLK 128 |
| 42 | 42 | ||
| 43 | time_t start_time, end_time; | ||
| 44 | 43 | ||
| 45 | void usage(const char *msg) { | 44 | void usage(const char *msg) { |
| 46 | printf("%s\n", msg); | 45 | printf("%s\n", msg); |
| @@ -285,7 +284,8 @@ double delta_time(struct timeval tv) { | |||
| 285 | struct timeval now; | 284 | struct timeval now; |
| 286 | 285 | ||
| 287 | gettimeofday(&now, NULL); | 286 | gettimeofday(&now, NULL); |
| 288 | return ((double)(now.tv_sec - tv.tv_sec) + (double)(now.tv_usec - tv.tv_usec) / (double)1000000); | 287 | return ((double)(now.tv_sec - tv.tv_sec) + |
| 288 | (double)(now.tv_usec - tv.tv_usec) / (double)1000000); | ||
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | long deltime(struct timeval tv) { | 291 | long deltime(struct timeval tv) { |
| @@ -507,8 +507,8 @@ int xasprintf(char **strp, const char *fmt, ...) { | |||
| 507 | * | 507 | * |
| 508 | ******************************************************************************/ | 508 | ******************************************************************************/ |
| 509 | 509 | ||
| 510 | char *perfdata(const char *label, long int val, const char *uom, bool warnp, long int warn, bool critp, long int crit, bool minp, | 510 | char *perfdata(const char *label, long int val, const char *uom, bool warnp, long int warn, |
| 511 | long int minv, bool maxp, long int maxv) { | 511 | bool critp, long int crit, bool minp, long int minv, bool maxp, long int maxv) { |
| 512 | char *data = NULL; | 512 | char *data = NULL; |
| 513 | 513 | ||
| 514 | if (strpbrk(label, "'= ")) { | 514 | if (strpbrk(label, "'= ")) { |
| @@ -542,10 +542,11 @@ char *perfdata(const char *label, long int val, const char *uom, bool warnp, lon | |||
| 542 | return data; | 542 | return data; |
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | char *perfdata_uint64(const char *label, uint64_t val, const char *uom, bool warnp, /* Warning present */ | 545 | char *perfdata_uint64(const char *label, uint64_t val, const char *uom, |
| 546 | uint64_t warn, bool critp, /* Critical present */ | 546 | bool warnp, /* Warning present */ |
| 547 | uint64_t crit, bool minp, /* Minimum present */ | 547 | uint64_t warn, bool critp, /* Critical present */ |
| 548 | uint64_t minv, bool maxp, /* Maximum present */ | 548 | uint64_t crit, bool minp, /* Minimum present */ |
| 549 | uint64_t minv, bool maxp, /* Maximum present */ | ||
| 549 | uint64_t maxv) { | 550 | uint64_t maxv) { |
| 550 | char *data = NULL; | 551 | char *data = NULL; |
| 551 | 552 | ||
| @@ -580,10 +581,11 @@ char *perfdata_uint64(const char *label, uint64_t val, const char *uom, bool war | |||
| 580 | return data; | 581 | return data; |
| 581 | } | 582 | } |
| 582 | 583 | ||
| 583 | char *perfdata_int64(const char *label, int64_t val, const char *uom, bool warnp, /* Warning present */ | 584 | char *perfdata_int64(const char *label, int64_t val, const char *uom, |
| 584 | int64_t warn, bool critp, /* Critical present */ | 585 | bool warnp, /* Warning present */ |
| 585 | int64_t crit, bool minp, /* Minimum present */ | 586 | int64_t warn, bool critp, /* Critical present */ |
| 586 | int64_t minv, bool maxp, /* Maximum present */ | 587 | int64_t crit, bool minp, /* Minimum present */ |
| 588 | int64_t minv, bool maxp, /* Maximum present */ | ||
| 587 | int64_t maxv) { | 589 | int64_t maxv) { |
| 588 | char *data = NULL; | 590 | char *data = NULL; |
| 589 | 591 | ||
| @@ -618,8 +620,8 @@ char *perfdata_int64(const char *label, int64_t val, const char *uom, bool warnp | |||
| 618 | return data; | 620 | return data; |
| 619 | } | 621 | } |
| 620 | 622 | ||
| 621 | char *fperfdata(const char *label, double val, const char *uom, bool warnp, double warn, bool critp, double crit, bool minp, double minv, | 623 | char *fperfdata(const char *label, double val, const char *uom, bool warnp, double warn, bool critp, |
| 622 | bool maxp, double maxv) { | 624 | double crit, bool minp, double minv, bool maxp, double maxv) { |
| 623 | char *data = NULL; | 625 | char *data = NULL; |
| 624 | 626 | ||
| 625 | if (strpbrk(label, "'= ")) { | 627 | if (strpbrk(label, "'= ")) { |
| @@ -655,7 +657,8 @@ char *fperfdata(const char *label, double val, const char *uom, bool warnp, doub | |||
| 655 | return data; | 657 | return data; |
| 656 | } | 658 | } |
| 657 | 659 | ||
| 658 | char *sperfdata(const char *label, double val, const char *uom, char *warn, char *crit, bool minp, double minv, bool maxp, double maxv) { | 660 | char *sperfdata(const char *label, double val, const char *uom, char *warn, char *crit, bool minp, |
| 661 | double minv, bool maxp, double maxv) { | ||
| 659 | char *data = NULL; | 662 | char *data = NULL; |
| 660 | if (strpbrk(label, "'= ")) { | 663 | if (strpbrk(label, "'= ")) { |
| 661 | xasprintf(&data, "'%s'=", label); | 664 | xasprintf(&data, "'%s'=", label); |
| @@ -690,7 +693,8 @@ char *sperfdata(const char *label, double val, const char *uom, char *warn, char | |||
| 690 | return data; | 693 | return data; |
| 691 | } | 694 | } |
| 692 | 695 | ||
| 693 | char *sperfdata_int(const char *label, int val, const char *uom, char *warn, char *crit, bool minp, int minv, bool maxp, int maxv) { | 696 | char *sperfdata_int(const char *label, int val, const char *uom, char *warn, char *crit, bool minp, |
| 697 | int minv, bool maxp, int maxv) { | ||
| 694 | char *data = NULL; | 698 | char *data = NULL; |
| 695 | if (strpbrk(label, "'= ")) { | 699 | if (strpbrk(label, "'= ")) { |
| 696 | xasprintf(&data, "'%s'=", label); | 700 | xasprintf(&data, "'%s'=", label); |
