[Nagiosplug-checkins] nagiosplug/lib utils_base.c, 1.2, 1.3 utils_base.h, 1.2, 1.3

Ton Voon tonvoon at users.sourceforge.net
Wed Oct 18 14:03:12 CEST 2006


Update of /cvsroot/nagiosplug/nagiosplug/lib
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv4834/lib

Modified Files:
	utils_base.c utils_base.h 
Log Message:
Cater for different errors when setting thresholds


Index: utils_base.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/utils_base.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- utils_base.c	14 Jul 2006 09:47:25 -0000	1.2
+++ utils_base.c	18 Oct 2006 12:03:10 -0000	1.3
@@ -96,12 +96,12 @@
 
 	if (warn_string != NULL) {
 		if ((temp_thresholds->warning = parse_range_string(warn_string)) == NULL) {
-			return 1;
+			return NP_RANGE_UNPARSEABLE;
 		}
 	}
 	if (critical_string != NULL) {
 		if ((temp_thresholds->critical = parse_range_string(critical_string)) == NULL) {
-			return 1;
+			return NP_RANGE_UNPARSEABLE;
 		}
 	}
 
@@ -117,10 +117,14 @@
 void
 set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_string)
 {
-	if (_set_thresholds(my_thresholds, warn_string, critical_string) == 0) {
+	switch (_set_thresholds(my_thresholds, warn_string, critical_string)) {
+	case 0:
 		return;
-	} else {
+	case NP_RANGE_UNPARSEABLE:
 		die(STATE_UNKNOWN, _("Range format incorrect"));
+	case NP_WARN_WITHIN_CRIT:
+		die(STATE_UNKNOWN, _("Warning level is a subset of critical and will not be alerted"));
+		break;
 	}
 }
 

Index: utils_base.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/utils_base.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- utils_base.h	2 Sep 2006 20:41:18 -0000	1.2
+++ utils_base.h	18 Oct 2006 12:03:10 -0000	1.3
@@ -38,4 +38,8 @@
 
 void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
 
+/* Return codes for _set_thresholds */
+#define NP_RANGE_UNPARSEABLE 1
+#define NP_WARN_WITHIN_CRIT 2
+
 #endif /* _UTILS_BASE_ */





More information about the Commits mailing list