summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-26 10:44:14 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-26 10:44:14 +0000
commit68e8cc5f4dde114f706e28130b6c0f2779706a01 (patch)
treeb49a0330a9700e344c3df5542b52e2f1ad6c3fbd /plugins/utils.c
parent1db3424e5f6b0b8cfbf41a287fe48296931be72b (diff)
downloadmonitoring-plugins-68e8cc5f4dde114f706e28130b6c0f2779706a01.tar.gz
function to make perfdata output
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@696 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 5c809ece..aad30068 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
510char *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}