diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils_base.c | 15 | ||||
-rw-r--r-- | lib/utils_base.h | 5 |
2 files changed, 11 insertions, 9 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c index c49a473f..60103614 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c | |||
@@ -25,6 +25,7 @@ | |||
25 | *****************************************************************************/ | 25 | *****************************************************************************/ |
26 | 26 | ||
27 | #include "../plugins/common.h" | 27 | #include "../plugins/common.h" |
28 | #include "states.h" | ||
28 | #include <stdarg.h> | 29 | #include <stdarg.h> |
29 | #include "utils_base.h" | 30 | #include "utils_base.h" |
30 | #include <ctype.h> | 31 | #include <ctype.h> |
@@ -256,21 +257,21 @@ bool check_range(double value, range *my_range) { | |||
256 | yes = false; | 257 | yes = false; |
257 | } | 258 | } |
258 | 259 | ||
259 | if (my_range->end_infinity == false && my_range->start_infinity == false) { | 260 | if (!my_range->end_infinity&& !my_range->start_infinity) { |
260 | if ((my_range->start <= value) && (value <= my_range->end)) { | 261 | if ((my_range->start <= value) && (value <= my_range->end)) { |
261 | return no; | 262 | return no; |
262 | } | 263 | } |
263 | return yes; | 264 | return yes; |
264 | } | 265 | } |
265 | 266 | ||
266 | if (my_range->start_infinity == false && my_range->end_infinity == true) { | 267 | if (!my_range->start_infinity && my_range->end_infinity) { |
267 | if (my_range->start <= value) { | 268 | if (my_range->start <= value) { |
268 | return no; | 269 | return no; |
269 | } | 270 | } |
270 | return yes; | 271 | return yes; |
271 | } | 272 | } |
272 | 273 | ||
273 | if (my_range->start_infinity == true && my_range->end_infinity == false) { | 274 | if (my_range->start_infinity && !my_range->end_infinity ) { |
274 | if (value <= my_range->end) { | 275 | if (value <= my_range->end) { |
275 | return no; | 276 | return no; |
276 | } | 277 | } |
@@ -280,14 +281,14 @@ bool check_range(double value, range *my_range) { | |||
280 | } | 281 | } |
281 | 282 | ||
282 | /* Returns status */ | 283 | /* Returns status */ |
283 | int get_status(double value, thresholds *my_thresholds) { | 284 | mp_state_enum get_status(double value, thresholds *my_thresholds) { |
284 | if (my_thresholds->critical != NULL) { | 285 | if (my_thresholds->critical != NULL) { |
285 | if (check_range(value, my_thresholds->critical) == true) { | 286 | if (check_range(value, my_thresholds->critical)) { |
286 | return STATE_CRITICAL; | 287 | return STATE_CRITICAL; |
287 | } | 288 | } |
288 | } | 289 | } |
289 | if (my_thresholds->warning != NULL) { | 290 | if (my_thresholds->warning != NULL) { |
290 | if (check_range(value, my_thresholds->warning) == true) { | 291 | if (check_range(value, my_thresholds->warning)) { |
291 | return STATE_WARNING; | 292 | return STATE_WARNING; |
292 | } | 293 | } |
293 | } | 294 | } |
@@ -395,7 +396,7 @@ char *np_extract_value(const char *varlist, const char *name, char sep) { | |||
395 | return value; | 396 | return value; |
396 | } | 397 | } |
397 | 398 | ||
398 | const char *state_text(int result) { | 399 | const char *state_text(mp_state_enum result) { |
399 | switch (result) { | 400 | switch (result) { |
400 | case STATE_OK: | 401 | case STATE_OK: |
401 | return "OK"; | 402 | return "OK"; |
diff --git a/lib/utils_base.h b/lib/utils_base.h index 123066f8..8fb114c2 100644 --- a/lib/utils_base.h +++ b/lib/utils_base.h | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include "./perfdata.h" | 8 | #include "./perfdata.h" |
9 | #include "./thresholds.h" | 9 | #include "./thresholds.h" |
10 | #include "states.h" | ||
10 | 11 | ||
11 | 12 | ||
12 | #ifndef USE_OPENSSL | 13 | #ifndef USE_OPENSSL |
@@ -55,7 +56,7 @@ void set_thresholds(thresholds **, char *, char *); | |||
55 | void print_thresholds(const char *, thresholds *); | 56 | void print_thresholds(const char *, thresholds *); |
56 | bool check_range(double, range *); | 57 | bool check_range(double, range *); |
57 | bool mp_check_range(mp_perfdata_value, mp_range); | 58 | bool mp_check_range(mp_perfdata_value, mp_range); |
58 | int get_status(double, thresholds *); | 59 | mp_state_enum get_status(double, thresholds *); |
59 | 60 | ||
60 | /* Handle timeouts */ | 61 | /* Handle timeouts */ |
61 | extern int timeout_state; | 62 | extern int timeout_state; |
@@ -107,6 +108,6 @@ void np_state_write_string(time_t, char *); | |||
107 | void np_init(char *, int argc, char **argv); | 108 | void np_init(char *, int argc, char **argv); |
108 | void np_set_args(int argc, char **argv); | 109 | void np_set_args(int argc, char **argv); |
109 | void np_cleanup(void); | 110 | void np_cleanup(void); |
110 | const char *state_text(int); | 111 | const char *state_text(mp_state_enum); |
111 | 112 | ||
112 | #endif /* _UTILS_BASE_ */ | 113 | #endif /* _UTILS_BASE_ */ |