summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorJohn C. Frickson <jfrickson@nagios.com>2016-11-07 19:06:05 (GMT)
committerSven Nierlein <sven@nierlein.de>2016-11-07 20:36:25 (GMT)
commita5983eda69b442a90495909803724901669b50fb (patch)
treefa3442fe3bc20309245188d88d77c6cdd15c17d9 /plugins/utils.c
parent3a12034805caf6c4ad21a8f86c8e4a43ff62576c (diff)
downloadmonitoring-plugins-a5983eda69b442a90495909803724901669b50fb.tar.gz
check_users not correctly detecting thresholds
Fix for issue https://github.com/nagios-plugins/nagios-plugins/issues/81 check_users now uses the standard warning and critical ranges parser and a standard perdata output routine.
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index a864e4a..231af92 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -668,3 +668,44 @@ char *sperfdata (const char *label,
668 668
669 return data; 669 return data;
670} 670}
671
672char *sperfdata_int (const char *label,
673 int val,
674 const char *uom,
675 char *warn,
676 char *crit,
677 int minp,
678 int minv,
679 int maxp,
680 int maxv)
681{
682 char *data = NULL;
683 if (strpbrk (label, "'= "))
684 xasprintf (&data, "'%s'=", label);
685 else
686 xasprintf (&data, "%s=", label);
687
688 xasprintf (&data, "%s%d", data, val);
689 xasprintf (&data, "%s%s;", data, uom);
690
691 if (warn!=NULL)
692 xasprintf (&data, "%s%s", data, warn);
693
694 xasprintf (&data, "%s;", data);
695
696 if (crit!=NULL)
697 xasprintf (&data, "%s%s", data, crit);
698
699 xasprintf (&data, "%s;", data);
700
701 if (minp)
702 xasprintf (&data, "%s%d", data, minv);
703
704 if (maxp) {
705 xasprintf (&data, "%s;", data);
706 xasprintf (&data, "%s%d", data, maxv);
707 }
708
709 return data;
710}
711