diff options
-rw-r--r-- | plugins/check_snmp.c | 158 |
1 files changed, 78 insertions, 80 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 937b3a5..90a0402 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -55,8 +55,6 @@ const char *email = "devel@monitoring-plugins.org"; | |||
55 | #define CRIT_STRING 2 | 55 | #define CRIT_STRING 2 |
56 | #define CRIT_REGEX 4 | 56 | #define CRIT_REGEX 4 |
57 | #define WARN_PRESENT 8 | 57 | #define WARN_PRESENT 8 |
58 | #define WARN_STRING 16 | ||
59 | #define WARN_REGEX 32 | ||
60 | 58 | ||
61 | #define OID_COUNT_STEP 8 | 59 | #define OID_COUNT_STEP 8 |
62 | 60 | ||
@@ -86,82 +84,82 @@ const char *email = "devel@monitoring-plugins.org"; | |||
86 | 84 | ||
87 | 85 | ||
88 | 86 | ||
89 | int process_arguments (int, char **); | 87 | static int process_arguments (int, char **); |
90 | int validate_arguments (void); | 88 | static int validate_arguments (void); |
91 | char *thisarg (char *str); | 89 | static char *thisarg (char *str); |
92 | char *nextarg (char *str); | 90 | static char *nextarg (char *str); |
93 | void print_usage (void); | 91 | void print_usage (void); |
94 | void print_help (void); | 92 | static void print_help (void); |
95 | char *multiply (char *str); | 93 | static char *multiply (char *str); |
96 | 94 | ||
97 | #include "regex.h" | 95 | #include "regex.h" |
98 | char regex_expect[MAX_INPUT_BUFFER] = ""; | 96 | static char regex_expect[MAX_INPUT_BUFFER] = ""; |
99 | regex_t preg; | 97 | static regex_t preg; |
100 | regmatch_t pmatch[10]; | 98 | static regmatch_t pmatch[10]; |
101 | char errbuf[MAX_INPUT_BUFFER] = ""; | 99 | static char errbuf[MAX_INPUT_BUFFER] = ""; |
102 | char perfstr[MAX_INPUT_BUFFER] = "| "; | 100 | static char perfstr[MAX_INPUT_BUFFER] = "| "; |
103 | int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | 101 | static int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; |
104 | int eflags = 0; | 102 | static int eflags = 0; |
105 | int errcode, excode; | 103 | static int errcode, excode; |
106 | 104 | ||
107 | char *server_address = NULL; | 105 | static char *server_address = NULL; |
108 | char *community = NULL; | 106 | static char *community = NULL; |
109 | char **contextargs = NULL; | 107 | static char **contextargs = NULL; |
110 | char *context = NULL; | 108 | static char *context = NULL; |
111 | char **authpriv = NULL; | 109 | static char **authpriv = NULL; |
112 | char *proto = NULL; | 110 | static char *proto = NULL; |
113 | char *seclevel = NULL; | 111 | static char *seclevel = NULL; |
114 | char *secname = NULL; | 112 | static char *secname = NULL; |
115 | char *authproto = NULL; | 113 | static char *authproto = NULL; |
116 | char *privproto = NULL; | 114 | static char *privproto = NULL; |
117 | char *authpasswd = NULL; | 115 | static char *authpasswd = NULL; |
118 | char *privpasswd = NULL; | 116 | static char *privpasswd = NULL; |
119 | int nulloid = STATE_UNKNOWN; | 117 | static int nulloid = STATE_UNKNOWN; |
120 | char **oids = NULL; | 118 | static char **oids = NULL; |
121 | size_t oids_size = 0; | 119 | static size_t oids_size = 0; |
122 | char *label; | 120 | static char *label; |
123 | char *units; | 121 | static char *units; |
124 | char *port; | 122 | static char *port; |
125 | char *snmpcmd; | 123 | static char *snmpcmd; |
126 | char string_value[MAX_INPUT_BUFFER] = ""; | 124 | static char string_value[MAX_INPUT_BUFFER] = ""; |
127 | int invert_search=0; | 125 | static int invert_search=0; |
128 | char **labels = NULL; | 126 | static char **labels = NULL; |
129 | char **unitv = NULL; | 127 | static char **unitv = NULL; |
130 | size_t nlabels = 0; | 128 | static size_t nlabels = 0; |
131 | size_t labels_size = OID_COUNT_STEP; | 129 | static size_t labels_size = OID_COUNT_STEP; |
132 | size_t nunits = 0; | 130 | static size_t nunits = 0; |
133 | size_t unitv_size = OID_COUNT_STEP; | 131 | static size_t unitv_size = OID_COUNT_STEP; |
134 | size_t numoids = 0; | 132 | static size_t numoids = 0; |
135 | int numauthpriv = 0; | 133 | static int numauthpriv = 0; |
136 | int numcontext = 0; | 134 | static int numcontext = 0; |
137 | int verbose = 0; | 135 | static int verbose = 0; |
138 | bool usesnmpgetnext = false; | 136 | static bool usesnmpgetnext = false; |
139 | char *warning_thresholds = NULL; | 137 | static char *warning_thresholds = NULL; |
140 | char *critical_thresholds = NULL; | 138 | static char *critical_thresholds = NULL; |
141 | thresholds **thlds; | 139 | static thresholds **thlds; |
142 | size_t thlds_size = OID_COUNT_STEP; | 140 | static size_t thlds_size = OID_COUNT_STEP; |
143 | double *response_value; | 141 | static double *response_value; |
144 | size_t response_size = OID_COUNT_STEP; | 142 | static size_t response_size = OID_COUNT_STEP; |
145 | int retries = 0; | 143 | static int retries = 0; |
146 | int *eval_method; | 144 | static int *eval_method; |
147 | size_t eval_size = OID_COUNT_STEP; | 145 | static size_t eval_size = OID_COUNT_STEP; |
148 | char *delimiter; | 146 | static char *delimiter; |
149 | char *output_delim; | 147 | static char *output_delim; |
150 | char *miblist = NULL; | 148 | static char *miblist = NULL; |
151 | bool needmibs = false; | 149 | static bool needmibs = false; |
152 | int calculate_rate = 0; | 150 | static int calculate_rate = 0; |
153 | double offset = 0.0; | 151 | static double offset = 0.0; |
154 | int rate_multiplier = 1; | 152 | static int rate_multiplier = 1; |
155 | state_data *previous_state; | 153 | static state_data *previous_state; |
156 | double *previous_value; | 154 | static double *previous_value; |
157 | size_t previous_size = OID_COUNT_STEP; | 155 | static size_t previous_size = OID_COUNT_STEP; |
158 | int perf_labels = 1; | 156 | static int perf_labels = 1; |
159 | char* ip_version = ""; | 157 | static char* ip_version = ""; |
160 | double multiplier = 1.0; | 158 | static double multiplier = 1.0; |
161 | char *fmtstr = ""; | 159 | static char *fmtstr = ""; |
162 | bool fmtstr_set = false; | 160 | static bool fmtstr_set = false; |
163 | char buffer[DEFAULT_BUFFER_SIZE]; | 161 | static char buffer[DEFAULT_BUFFER_SIZE]; |
164 | bool ignore_mib_parsing_errors = false; | 162 | static bool ignore_mib_parsing_errors = false; |
165 | 163 | ||
166 | static char *fix_snmp_range(char *th) | 164 | static char *fix_snmp_range(char *th) |
167 | { | 165 | { |
@@ -1030,7 +1028,7 @@ selected.</para> | |||
1030 | 1028 | ||
1031 | 1029 | ||
1032 | 1030 | ||
1033 | int | 1031 | static int |
1034 | validate_arguments () | 1032 | validate_arguments () |
1035 | { | 1033 | { |
1036 | /* check whether to load locally installed MIBS (CPU/disk intensive) */ | 1034 | /* check whether to load locally installed MIBS (CPU/disk intensive) */ |
@@ -1139,7 +1137,7 @@ validate_arguments () | |||
1139 | /* trim leading whitespace | 1137 | /* trim leading whitespace |
1140 | if there is a leading quote, make sure it balances */ | 1138 | if there is a leading quote, make sure it balances */ |
1141 | 1139 | ||
1142 | char * | 1140 | static char * |
1143 | thisarg (char *str) | 1141 | thisarg (char *str) |
1144 | { | 1142 | { |
1145 | str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ | 1143 | str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ |
@@ -1156,7 +1154,7 @@ thisarg (char *str) | |||
1156 | set the trailing quote to '\x0' | 1154 | set the trailing quote to '\x0' |
1157 | if the string continues, advance beyond the comma */ | 1155 | if the string continues, advance beyond the comma */ |
1158 | 1156 | ||
1159 | char * | 1157 | static char * |
1160 | nextarg (char *str) | 1158 | nextarg (char *str) |
1161 | { | 1159 | { |
1162 | if (str[0] == '\'') { | 1160 | if (str[0] == '\'') { |
@@ -1188,7 +1186,7 @@ nextarg (char *str) | |||
1188 | 1186 | ||
1189 | 1187 | ||
1190 | /* multiply result (values 0 < n < 1 work as divider) */ | 1188 | /* multiply result (values 0 < n < 1 work as divider) */ |
1191 | char * | 1189 | static char * |
1192 | multiply (char *str) | 1190 | multiply (char *str) |
1193 | { | 1191 | { |
1194 | char *endptr; | 1192 | char *endptr; |
@@ -1225,7 +1223,7 @@ multiply (char *str) | |||
1225 | } | 1223 | } |
1226 | 1224 | ||
1227 | 1225 | ||
1228 | void | 1226 | static void |
1229 | print_help (void) | 1227 | print_help (void) |
1230 | { | 1228 | { |
1231 | print_revision (progname, NP_VERSION); | 1229 | print_revision (progname, NP_VERSION); |