diff options
Diffstat (limited to 'plugins/utils.c')
-rw-r--r-- | plugins/utils.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c index 5c809ec..aad3006 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -497,3 +497,47 @@ strpcat (char *dest, const char *src, const char *str) | |||
497 | 497 | ||
498 | return dest; | 498 | return dest; |
499 | } | 499 | } |
500 | |||
501 | |||
502 | |||
503 | |||
504 | /****************************************************************************** | ||
505 | * | ||
506 | * Print perfdata in a standard format | ||
507 | * | ||
508 | ******************************************************************************/ | ||
509 | |||
510 | char *perfdata (const char *label, | ||
511 | long int val, | ||
512 | const char *uom, | ||
513 | int warnp, | ||
514 | long int warn, | ||
515 | int critp, | ||
516 | long int crit, | ||
517 | int minp, | ||
518 | long int minv, | ||
519 | int maxp, | ||
520 | long int maxv) | ||
521 | { | ||
522 | char *data = NULL; | ||
523 | |||
524 | asprintf (&data, "\"%s\"=%ld%s;", label, val, uom); | ||
525 | |||
526 | if (warnp) | ||
527 | asprintf (&data, "%s%ld;", data, warn); | ||
528 | else | ||
529 | asprintf (&data, "%s;", data); | ||
530 | |||
531 | if (critp) | ||
532 | asprintf (&data, "%s%ld;", data, crit); | ||
533 | else | ||
534 | asprintf (&data, "%s;", data); | ||
535 | |||
536 | if (minp) | ||
537 | asprintf (&data, "%s%ld", data, minv); | ||
538 | |||
539 | if (maxp) | ||
540 | asprintf (&data, "%s;%ld", data, maxv); | ||
541 | |||
542 | return data; | ||
543 | } | ||