diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/common.h | 9 | ||||
-rw-r--r-- | plugins/popen.c | 1 | ||||
-rw-r--r-- | plugins/runcmd.c | 1 | ||||
-rw-r--r-- | plugins/sslutils.c | 1 | ||||
-rw-r--r-- | plugins/utils.c | 48 | ||||
-rw-r--r-- | plugins/utils.h | 11 |
6 files changed, 7 insertions, 64 deletions
diff --git a/plugins/common.h b/plugins/common.h index 833479ce..47b1e4df 100644 --- a/plugins/common.h +++ b/plugins/common.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #define _COMMON_H_ | 32 | #define _COMMON_H_ |
33 | 33 | ||
34 | #include "config.h" | 34 | #include "config.h" |
35 | #include "../lib/monitoringplug.h" | ||
35 | 36 | ||
36 | #ifdef HAVE_FEATURES_H | 37 | #ifdef HAVE_FEATURES_H |
37 | #include <features.h> | 38 | #include <features.h> |
@@ -185,14 +186,6 @@ enum { | |||
185 | }; | 186 | }; |
186 | 187 | ||
187 | enum { | 188 | enum { |
188 | STATE_OK, | ||
189 | STATE_WARNING, | ||
190 | STATE_CRITICAL, | ||
191 | STATE_UNKNOWN, | ||
192 | STATE_DEPENDENT | ||
193 | }; | ||
194 | |||
195 | enum { | ||
196 | DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */ | 189 | DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */ |
197 | MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */ | 190 | MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */ |
198 | MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */ | 191 | MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */ |
diff --git a/plugins/popen.c b/plugins/popen.c index 2b9824bc..cfe930b6 100644 --- a/plugins/popen.c +++ b/plugins/popen.c | |||
@@ -40,7 +40,6 @@ | |||
40 | 40 | ||
41 | #include "./common.h" | 41 | #include "./common.h" |
42 | #include "./utils.h" | 42 | #include "./utils.h" |
43 | #include "../lib/maxfd.h" | ||
44 | 43 | ||
45 | /* extern so plugin has pid to kill exec'd process on timeouts */ | 44 | /* extern so plugin has pid to kill exec'd process on timeouts */ |
46 | extern pid_t *childpid; | 45 | extern pid_t *childpid; |
diff --git a/plugins/runcmd.c b/plugins/runcmd.c index 74843149..4429ceb0 100644 --- a/plugins/runcmd.c +++ b/plugins/runcmd.c | |||
@@ -40,6 +40,7 @@ | |||
40 | 40 | ||
41 | /** includes **/ | 41 | /** includes **/ |
42 | #include "runcmd.h" | 42 | #include "runcmd.h" |
43 | #include "../lib/monitoringplug.h" | ||
43 | #ifdef HAVE_SYS_WAIT_H | 44 | #ifdef HAVE_SYS_WAIT_H |
44 | # include <sys/wait.h> | 45 | # include <sys/wait.h> |
45 | #endif | 46 | #endif |
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index 3c928413..719de575 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #define MAX_CN_LENGTH 256 | 29 | #define MAX_CN_LENGTH 256 |
30 | #include "common.h" | 30 | #include "common.h" |
31 | #include "netutils.h" | 31 | #include "netutils.h" |
32 | #include "../lib/monitoringplug.h" | ||
32 | 33 | ||
33 | #ifdef HAVE_SSL | 34 | #ifdef HAVE_SSL |
34 | static SSL_CTX *ctx = NULL; | 35 | static SSL_CTX *ctx = NULL; |
diff --git a/plugins/utils.c b/plugins/utils.c index 6d366e3d..09649429 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -42,54 +42,6 @@ extern const char *progname; | |||
42 | 42 | ||
43 | time_t start_time, end_time; | 43 | time_t start_time, end_time; |
44 | 44 | ||
45 | /* ************************************************************************** | ||
46 | * max_state(STATE_x, STATE_y) | ||
47 | * compares STATE_x to STATE_y and returns result based on the following | ||
48 | * STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL | ||
49 | * | ||
50 | * Note that numerically the above does not hold | ||
51 | ****************************************************************************/ | ||
52 | |||
53 | int max_state(int a, int b) { | ||
54 | if (a == STATE_CRITICAL || b == STATE_CRITICAL) | ||
55 | return STATE_CRITICAL; | ||
56 | else if (a == STATE_WARNING || b == STATE_WARNING) | ||
57 | return STATE_WARNING; | ||
58 | else if (a == STATE_OK || b == STATE_OK) | ||
59 | return STATE_OK; | ||
60 | else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) | ||
61 | return STATE_UNKNOWN; | ||
62 | else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) | ||
63 | return STATE_DEPENDENT; | ||
64 | else | ||
65 | return max(a, b); | ||
66 | } | ||
67 | |||
68 | /* ************************************************************************** | ||
69 | * max_state_alt(STATE_x, STATE_y) | ||
70 | * compares STATE_x to STATE_y and returns result based on the following | ||
71 | * STATE_OK < STATE_DEPENDENT < STATE_UNKNOWN < STATE_WARNING < STATE_CRITICAL | ||
72 | * | ||
73 | * The main difference between max_state_alt and max_state it that it doesn't | ||
74 | * allow setting a default to UNKNOWN. It will instead prioritixe any valid | ||
75 | * non-OK state. | ||
76 | ****************************************************************************/ | ||
77 | |||
78 | int max_state_alt(int a, int b) { | ||
79 | if (a == STATE_CRITICAL || b == STATE_CRITICAL) | ||
80 | return STATE_CRITICAL; | ||
81 | else if (a == STATE_WARNING || b == STATE_WARNING) | ||
82 | return STATE_WARNING; | ||
83 | else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) | ||
84 | return STATE_UNKNOWN; | ||
85 | else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) | ||
86 | return STATE_DEPENDENT; | ||
87 | else if (a == STATE_OK || b == STATE_OK) | ||
88 | return STATE_OK; | ||
89 | else | ||
90 | return max(a, b); | ||
91 | } | ||
92 | |||
93 | void usage(const char *msg) { | 45 | void usage(const char *msg) { |
94 | printf("%s\n", msg); | 46 | printf("%s\n", msg); |
95 | print_usage(); | 47 | print_usage(); |
diff --git a/plugins/utils.h b/plugins/utils.h index f939e337..c7073990 100644 --- a/plugins/utils.h +++ b/plugins/utils.h | |||
@@ -13,11 +13,11 @@ in order to resist overflow attacks. In addition, a few functions are | |||
13 | provided to standardize version and error reporting across the entire | 13 | provided to standardize version and error reporting across the entire |
14 | suite of plugins. */ | 14 | suite of plugins. */ |
15 | 15 | ||
16 | /* now some functions etc are being defined in ../lib/utils_base.c */ | 16 | #include "../config.h" |
17 | #include "utils_base.h" | ||
18 | |||
19 | #include <stdbool.h> | 17 | #include <stdbool.h> |
20 | 18 | #include <stdint.h> | |
19 | #include <stdio.h> | ||
20 | #include <time.h> | ||
21 | 21 | ||
22 | #ifdef NP_EXTRA_OPTS | 22 | #ifdef NP_EXTRA_OPTS |
23 | /* Include extra-opts functions if compiled in */ | 23 | /* Include extra-opts functions if compiled in */ |
@@ -78,9 +78,6 @@ char *strpcat (char *, const char *, const char *); | |||
78 | int xvasprintf (char **strp, const char *fmt, va_list ap); | 78 | int xvasprintf (char **strp, const char *fmt, va_list ap); |
79 | int xasprintf (char **strp, const char *fmt, ...); | 79 | int xasprintf (char **strp, const char *fmt, ...); |
80 | 80 | ||
81 | int max_state (int a, int b); | ||
82 | int max_state_alt (int a, int b); | ||
83 | |||
84 | void usage (const char *) __attribute__((noreturn)); | 81 | void usage (const char *) __attribute__((noreturn)); |
85 | void usage2(const char *, const char *) __attribute__((noreturn)); | 82 | void usage2(const char *, const char *) __attribute__((noreturn)); |
86 | void usage3(const char *, int) __attribute__((noreturn)); | 83 | void usage3(const char *, int) __attribute__((noreturn)); |