Parcourir la source

Cater for different errors when setting thresholds

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1496 f882894a-f735-0410-b71e-b25c423dba1c
Ton Voon il y a 19 ans
Parent
commit
c56c42b9c9
2 fichiers modifiés avec 12 ajouts et 4 suppressions
  1. 8 4
      lib/utils_base.c
  2. 4 0
      lib/utils_base.h

+ 8 - 4
lib/utils_base.c

@@ -96,12 +96,12 @@ _set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_st
 
 
 	if (warn_string != NULL) {
 	if (warn_string != NULL) {
 		if ((temp_thresholds->warning = parse_range_string(warn_string)) == NULL) {
 		if ((temp_thresholds->warning = parse_range_string(warn_string)) == NULL) {
-			return 1;
+			return NP_RANGE_UNPARSEABLE;
 		}
 		}
 	}
 	}
 	if (critical_string != NULL) {
 	if (critical_string != NULL) {
 		if ((temp_thresholds->critical = parse_range_string(critical_string)) == NULL) {
 		if ((temp_thresholds->critical = parse_range_string(critical_string)) == NULL) {
-			return 1;
+			return NP_RANGE_UNPARSEABLE;
 		}
 		}
 	}
 	}
 
 
@@ -117,10 +117,14 @@ _set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_st
 void
 void
 set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_string)
 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;
 		return;
-	} else {
+	case NP_RANGE_UNPARSEABLE:
 		die(STATE_UNKNOWN, _("Range format incorrect"));
 		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;
 	}
 	}
 }
 }
 
 

+ 4 - 0
lib/utils_base.h

@@ -38,4 +38,8 @@ char *np_escaped_string (const char *);
 
 
 void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
 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_ */
 #endif /* _UTILS_BASE_ */