diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/perfdata.h | 46 | ||||
-rw-r--r-- | lib/thresholds.h | 4 | ||||
-rw-r--r-- | lib/utils_base.c | 9 | ||||
-rw-r--r-- | lib/utils_base.h | 5 |
4 files changed, 33 insertions, 31 deletions
diff --git a/lib/perfdata.h b/lib/perfdata.h index c5d4a61d..e51ef5fd 100644 --- a/lib/perfdata.h +++ b/lib/perfdata.h | |||
@@ -28,7 +28,7 @@ typedef struct { | |||
28 | /* | 28 | /* |
29 | * New range type with generic numerical values | 29 | * New range type with generic numerical values |
30 | */ | 30 | */ |
31 | typedef struct mp_range_struct { | 31 | typedef struct { |
32 | mp_perfdata_value start; | 32 | mp_perfdata_value start; |
33 | bool start_infinity; /* false (default) or true */ | 33 | bool start_infinity; /* false (default) or true */ |
34 | 34 | ||
@@ -41,7 +41,7 @@ typedef struct mp_range_struct { | |||
41 | /* | 41 | /* |
42 | * Old range type with floating point values | 42 | * Old range type with floating point values |
43 | */ | 43 | */ |
44 | typedef struct range_struct { | 44 | typedef struct { |
45 | double start; | 45 | double start; |
46 | bool start_infinity; | 46 | bool start_infinity; |
47 | double end; | 47 | double end; |
@@ -53,7 +53,7 @@ typedef struct range_struct { | |||
53 | /* | 53 | /* |
54 | * Perfdata type for storing perfdata output | 54 | * Perfdata type for storing perfdata output |
55 | */ | 55 | */ |
56 | typedef struct perfdata_struct { | 56 | typedef struct { |
57 | char *label; | 57 | char *label; |
58 | char *uom; | 58 | char *uom; |
59 | mp_perfdata_value value; | 59 | mp_perfdata_value value; |
@@ -131,15 +131,15 @@ mp_range_parsed mp_parse_range_string(const char * /*input*/); | |||
131 | */ | 131 | */ |
132 | void pd_list_append(pd_list[1], mp_perfdata); | 132 | void pd_list_append(pd_list[1], mp_perfdata); |
133 | 133 | ||
134 | #define mp_set_pd_value(P, V) \ | 134 | #define mp_set_pd_value(P, V) \ |
135 | _Generic((V), \ | 135 | _Generic((V), \ |
136 | float: mp_set_pd_value_float, \ | 136 | float: mp_set_pd_value_float, \ |
137 | double: mp_set_pd_value_double, \ | 137 | double: mp_set_pd_value_double, \ |
138 | int: mp_set_pd_value_int, \ | 138 | int: mp_set_pd_value_int, \ |
139 | unsigned int: mp_set_pd_value_u_int, \ | 139 | unsigned int: mp_set_pd_value_u_int, \ |
140 | long: mp_set_pd_value_long, \ | 140 | long: mp_set_pd_value_long, \ |
141 | unsigned long: mp_set_pd_value_u_long, \ | 141 | unsigned long: mp_set_pd_value_u_long, \ |
142 | long long: mp_set_pd_value_long_long, \ | 142 | long long: mp_set_pd_value_long_long, \ |
143 | unsigned long long: mp_set_pd_value_u_long_long)(P, V) | 143 | unsigned long long: mp_set_pd_value_u_long_long)(P, V) |
144 | 144 | ||
145 | mp_perfdata mp_set_pd_value_float(mp_perfdata, float); | 145 | mp_perfdata mp_set_pd_value_float(mp_perfdata, float); |
@@ -151,17 +151,17 @@ mp_perfdata mp_set_pd_value_u_long(mp_perfdata, unsigned long); | |||
151 | mp_perfdata mp_set_pd_value_long_long(mp_perfdata, long long); | 151 | mp_perfdata mp_set_pd_value_long_long(mp_perfdata, long long); |
152 | mp_perfdata mp_set_pd_value_u_long_long(mp_perfdata, unsigned long long); | 152 | mp_perfdata mp_set_pd_value_u_long_long(mp_perfdata, unsigned long long); |
153 | 153 | ||
154 | #define mp_create_pd_value(V) \ | 154 | #define mp_create_pd_value(V) \ |
155 | _Generic((V), \ | 155 | _Generic((V), \ |
156 | float: mp_create_pd_value_float, \ | 156 | float: mp_create_pd_value_float, \ |
157 | double: mp_create_pd_value_double, \ | 157 | double: mp_create_pd_value_double, \ |
158 | char: mp_create_pd_value_char, \ | 158 | char: mp_create_pd_value_char, \ |
159 | unsigned char: mp_create_pd_value_u_char, \ | 159 | unsigned char: mp_create_pd_value_u_char, \ |
160 | int: mp_create_pd_value_int, \ | 160 | int: mp_create_pd_value_int, \ |
161 | unsigned int: mp_create_pd_value_u_int, \ | 161 | unsigned int: mp_create_pd_value_u_int, \ |
162 | long: mp_create_pd_value_long, \ | 162 | long: mp_create_pd_value_long, \ |
163 | unsigned long: mp_create_pd_value_u_long, \ | 163 | unsigned long: mp_create_pd_value_u_long, \ |
164 | long long: mp_create_pd_value_long_long, \ | 164 | long long: mp_create_pd_value_long_long, \ |
165 | unsigned long long: mp_create_pd_value_u_long_long)(V) | 165 | unsigned long long: mp_create_pd_value_u_long_long)(V) |
166 | 166 | ||
167 | mp_perfdata_value mp_create_pd_value_float(float); | 167 | mp_perfdata_value mp_create_pd_value_float(float); |
diff --git a/lib/thresholds.h b/lib/thresholds.h index 5f9f9247..f8647681 100644 --- a/lib/thresholds.h +++ b/lib/thresholds.h | |||
@@ -6,12 +6,12 @@ | |||
6 | /* | 6 | /* |
7 | * Old threshold type using the old range type | 7 | * Old threshold type using the old range type |
8 | */ | 8 | */ |
9 | typedef struct thresholds_struct { | 9 | typedef struct { |
10 | range *warning; | 10 | range *warning; |
11 | range *critical; | 11 | range *critical; |
12 | } thresholds; | 12 | } thresholds; |
13 | 13 | ||
14 | typedef struct mp_thresholds_struct { | 14 | typedef struct { |
15 | bool warning_is_set; | 15 | bool warning_is_set; |
16 | mp_range warning; | 16 | mp_range warning; |
17 | bool critical_is_set; | 17 | bool critical_is_set; |
diff --git a/lib/utils_base.c b/lib/utils_base.c index 29b393d0..e95eeaf0 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> |
@@ -253,7 +254,7 @@ bool check_range(double value, range *my_range) { | |||
253 | yes = false; | 254 | yes = false; |
254 | } | 255 | } |
255 | 256 | ||
256 | if (!my_range->end_infinity && !my_range->start_infinity) { | 257 | if (!my_range->end_infinity&& !my_range->start_infinity) { |
257 | if ((my_range->start <= value) && (value <= my_range->end)) { | 258 | if ((my_range->start <= value) && (value <= my_range->end)) { |
258 | return no; | 259 | return no; |
259 | } | 260 | } |
@@ -267,7 +268,7 @@ bool check_range(double value, range *my_range) { | |||
267 | return yes; | 268 | return yes; |
268 | } | 269 | } |
269 | 270 | ||
270 | if (my_range->start_infinity && !my_range->end_infinity) { | 271 | if (my_range->start_infinity && !my_range->end_infinity ) { |
271 | if (value <= my_range->end) { | 272 | if (value <= my_range->end) { |
272 | return no; | 273 | return no; |
273 | } | 274 | } |
@@ -277,7 +278,7 @@ bool check_range(double value, range *my_range) { | |||
277 | } | 278 | } |
278 | 279 | ||
279 | /* Returns status */ | 280 | /* Returns status */ |
280 | int get_status(double value, thresholds *my_thresholds) { | 281 | mp_state_enum get_status(double value, thresholds *my_thresholds) { |
281 | if (my_thresholds->critical != NULL) { | 282 | if (my_thresholds->critical != NULL) { |
282 | if (check_range(value, my_thresholds->critical)) { | 283 | if (check_range(value, my_thresholds->critical)) { |
283 | return STATE_CRITICAL; | 284 | return STATE_CRITICAL; |
@@ -393,7 +394,7 @@ char *np_extract_value(const char *varlist, const char *name, char sep) { | |||
393 | return value; | 394 | return value; |
394 | } | 395 | } |
395 | 396 | ||
396 | const char *state_text(int result) { | 397 | const char *state_text(mp_state_enum result) { |
397 | switch (result) { | 398 | switch (result) { |
398 | case STATE_OK: | 399 | case STATE_OK: |
399 | return "OK"; | 400 | return "OK"; |
diff --git a/lib/utils_base.h b/lib/utils_base.h index f1c99a54..f31299c4 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 | #ifndef USE_OPENSSL | 12 | #ifndef USE_OPENSSL |
12 | # include "sha256.h" | 13 | # include "sha256.h" |
@@ -37,7 +38,7 @@ void set_thresholds(thresholds **, char *, char *); | |||
37 | void print_thresholds(const char *, thresholds *); | 38 | void print_thresholds(const char *, thresholds *); |
38 | bool check_range(double, range *); | 39 | bool check_range(double, range *); |
39 | bool mp_check_range(mp_perfdata_value, mp_range); | 40 | bool mp_check_range(mp_perfdata_value, mp_range); |
40 | int get_status(double, thresholds *); | 41 | mp_state_enum get_status(double, thresholds *); |
41 | 42 | ||
42 | /* Handle timeouts */ | 43 | /* Handle timeouts */ |
43 | extern int timeout_state; | 44 | extern int timeout_state; |
@@ -85,6 +86,6 @@ int mp_translate_state(char *); | |||
85 | void np_init(char *, int argc, char **argv); | 86 | void np_init(char *, int argc, char **argv); |
86 | void np_set_args(int argc, char **argv); | 87 | void np_set_args(int argc, char **argv); |
87 | void np_cleanup(void); | 88 | void np_cleanup(void); |
88 | const char *state_text(int); | 89 | const char *state_text(mp_state_enum); |
89 | 90 | ||
90 | #endif /* _UTILS_BASE_ */ | 91 | #endif /* _UTILS_BASE_ */ |