summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-10-18 12:03:10 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-10-18 12:03:10 (GMT)
commitc56c42b9c999742ff3cfebf1cadc8c93ad68048c (patch)
tree78ab319e6f5bf4062af3022c6e1c0da2602a6790 /lib
parentd00a65f8172ea55b6b4938c65ae0568dbd03b9c0 (diff)
downloadmonitoring-plugins-c56c42b9c999742ff3cfebf1cadc8c93ad68048c.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/utils_base.c12
-rw-r--r--lib/utils_base.h4
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 3dae32f..18fb3f2 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -96,12 +96,12 @@ _set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_st
96 96
97 if (warn_string != NULL) { 97 if (warn_string != NULL) {
98 if ((temp_thresholds->warning = parse_range_string(warn_string)) == NULL) { 98 if ((temp_thresholds->warning = parse_range_string(warn_string)) == NULL) {
99 return 1; 99 return NP_RANGE_UNPARSEABLE;
100 } 100 }
101 } 101 }
102 if (critical_string != NULL) { 102 if (critical_string != NULL) {
103 if ((temp_thresholds->critical = parse_range_string(critical_string)) == NULL) { 103 if ((temp_thresholds->critical = parse_range_string(critical_string)) == NULL) {
104 return 1; 104 return NP_RANGE_UNPARSEABLE;
105 } 105 }
106 } 106 }
107 107
@@ -117,10 +117,14 @@ _set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_st
117void 117void
118set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_string) 118set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_string)
119{ 119{
120 if (_set_thresholds(my_thresholds, warn_string, critical_string) == 0) { 120 switch (_set_thresholds(my_thresholds, warn_string, critical_string)) {
121 case 0:
121 return; 122 return;
122 } else { 123 case NP_RANGE_UNPARSEABLE:
123 die(STATE_UNKNOWN, _("Range format incorrect")); 124 die(STATE_UNKNOWN, _("Range format incorrect"));
125 case NP_WARN_WITHIN_CRIT:
126 die(STATE_UNKNOWN, _("Warning level is a subset of critical and will not be alerted"));
127 break;
124 } 128 }
125} 129}
126 130
diff --git a/lib/utils_base.h b/lib/utils_base.h
index 113e304..44ed0a3 100644
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -38,4 +38,8 @@ char *np_escaped_string (const char *);
38 38
39void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3))); 39void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
40 40
41/* Return codes for _set_thresholds */
42#define NP_RANGE_UNPARSEABLE 1
43#define NP_WARN_WITHIN_CRIT 2
44
41#endif /* _UTILS_BASE_ */ 45#endif /* _UTILS_BASE_ */