diff options
author | Jeremy T. Bouse <undrgrid@users.sourceforge.net> | 2003-06-30 19:47:21 (GMT) |
---|---|---|
committer | Jeremy T. Bouse <undrgrid@users.sourceforge.net> | 2003-06-30 19:47:21 (GMT) |
commit | f813c747a264906c066d85d220e7b0f4aab3e046 (patch) | |
tree | ba8dd633c0a5b5e92355adb606d190cd0863023b /plugins | |
parent | 97634d8fc6bba849f771eda24106d88104e703b9 (diff) | |
download | monitoring-plugins-f813c747a264906c066d85d220e7b0f4aab3e046.tar.gz |
Added -4 and -6 command line options into check_http, check_ldap and
check_smtp
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@575 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_http.c | 20 | ||||
-rw-r--r-- | plugins/check_ldap.c | 30 | ||||
-rw-r--r-- | plugins/check_smtp.c | 20 |
3 files changed, 60 insertions, 10 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 468e4c2..038ac68 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -45,13 +45,17 @@ certificate expiration times.\n" | |||
45 | [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\ | 45 | [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\ |
46 | [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\ | 46 | [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\ |
47 | [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\ | 47 | [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\ |
48 | [-P string] [-m min_pg_size]" | 48 | [-P string] [-m min_pg_size] [-4|-6]" |
49 | 49 | ||
50 | #define LONGOPTIONS "\ | 50 | #define LONGOPTIONS "\ |
51 | -H, --hostname=ADDRESS\n\ | 51 | -H, --hostname=ADDRESS\n\ |
52 | Host name argument for servers using host headers (virtual host)\n\ | 52 | Host name argument for servers using host headers (virtual host)\n\ |
53 | -I, --IP-address=ADDRESS\n\ | 53 | -I, --IP-address=ADDRESS\n\ |
54 | IP address or name (use numeric address if possible to bypass DNS lookup).\n\ | 54 | IP address or name (use numeric address if possible to bypass DNS lookup).\n\ |
55 | -4, --use-ipv4\n\ | ||
56 | Use IPv4 protocol\n\ | ||
57 | -6, --use-ipv6\n\ | ||
58 | Use IPv6 protocol\n\ | ||
55 | -e, --expect=STRING\n\ | 59 | -e, --expect=STRING\n\ |
56 | String to expect in first (status) line of server response (default: %s)\n\ | 60 | String to expect in first (status) line of server response (default: %s)\n\ |
57 | If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)\n\ | 61 | If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)\n\ |
@@ -316,6 +320,8 @@ process_arguments (int argc, char **argv) | |||
316 | {"onredirect", required_argument, 0, 'f'}, | 320 | {"onredirect", required_argument, 0, 'f'}, |
317 | {"certificate", required_argument, 0, 'C'}, | 321 | {"certificate", required_argument, 0, 'C'}, |
318 | {"min", required_argument, 0, 'm'}, | 322 | {"min", required_argument, 0, 'm'}, |
323 | {"use-ipv4", no_argument, 0, '4'}, | ||
324 | {"use-ipv6", no_argument, 0, '6'}, | ||
319 | {0, 0, 0, 0} | 325 | {0, 0, 0, 0} |
320 | }; | 326 | }; |
321 | 327 | ||
@@ -336,7 +342,7 @@ process_arguments (int argc, char **argv) | |||
336 | } | 342 | } |
337 | 343 | ||
338 | while (1) { | 344 | while (1) { |
339 | c = getopt_long (argc, argv, "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLSm:", long_options, &option_index); | 345 | c = getopt_long (argc, argv, "Vvh46t:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLSm:", long_options, &option_index); |
340 | if (c == -1 || c == EOF) | 346 | if (c == -1 || c == EOF) |
341 | break; | 347 | break; |
342 | 348 | ||
@@ -464,6 +470,16 @@ process_arguments (int argc, char **argv) | |||
464 | } | 470 | } |
465 | break; | 471 | break; |
466 | #endif | 472 | #endif |
473 | case '4': | ||
474 | address_family = AF_INET; | ||
475 | break; | ||
476 | case '6': | ||
477 | #ifdef USE_IPV6 | ||
478 | address_family = AF_INET6; | ||
479 | #else | ||
480 | usage ("IPv6 support not available\n"); | ||
481 | #endif | ||
482 | break; | ||
467 | case 'v': /* verbose */ | 483 | case 'v': /* verbose */ |
468 | verbose = TRUE; | 484 | verbose = TRUE; |
469 | break; | 485 | break; |
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index 8eb8956..af919f2 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c | |||
@@ -159,6 +159,8 @@ process_arguments (int argc, char **argv) | |||
159 | {"ver2", no_argument, 0, '2'}, | 159 | {"ver2", no_argument, 0, '2'}, |
160 | {"ver3", no_argument, 0, '3'}, | 160 | {"ver3", no_argument, 0, '3'}, |
161 | #endif | 161 | #endif |
162 | {"use-ipv4", no_argument, 0, '4'}, | ||
163 | {"use-ipv6", no_argument, 0, '6'}, | ||
162 | {"port", required_argument, 0, 'p'}, | 164 | {"port", required_argument, 0, 'p'}, |
163 | {"warn", required_argument, 0, 'w'}, | 165 | {"warn", required_argument, 0, 'w'}, |
164 | {"crit", required_argument, 0, 'c'}, | 166 | {"crit", required_argument, 0, 'c'}, |
@@ -174,7 +176,7 @@ process_arguments (int argc, char **argv) | |||
174 | } | 176 | } |
175 | 177 | ||
176 | while (1) { | 178 | while (1) { |
177 | c = getopt_long (argc, argv, "hV23t:c:w:H:b:p:a:D:P:", longopts, &option_index); | 179 | c = getopt_long (argc, argv, "hV2346t:c:w:H:b:p:a:D:P:", longopts, &option_index); |
178 | 180 | ||
179 | if (c == -1 || c == EOF) | 181 | if (c == -1 || c == EOF) |
180 | break; | 182 | break; |
@@ -223,14 +225,28 @@ process_arguments (int argc, char **argv) | |||
223 | ld_protocol = 3; | 225 | ld_protocol = 3; |
224 | break; | 226 | break; |
225 | #endif | 227 | #endif |
228 | case '4': | ||
229 | address_family = AF_INET; | ||
230 | break; | ||
231 | case '6': | ||
232 | #ifdef USE_IPV6 | ||
233 | address_family = AF_INET6; | ||
234 | #else | ||
235 | usage ("IPv6 support not available\n"); | ||
236 | #endif | ||
237 | break; | ||
226 | default: | 238 | default: |
227 | usage ("check_ldap: could not parse unknown arguments\n"); | 239 | usage ("check_ldap: could not parse unknown arguments\n"); |
228 | break; | 240 | break; |
229 | } | 241 | } |
230 | } | 242 | } |
231 | 243 | ||
232 | if (ld_host[0] == 0) { | 244 | c = optind; |
233 | asprintf (&ld_host, "%s", argv[c]); | 245 | if (strlen(ld_host) == 0 && is_host(argv[c])) { |
246 | asprintf (&ld_host, "%s", argv[c++]); | ||
247 | } | ||
248 | if (strlen(ld_base) == 0 && argv[c]) { | ||
249 | asprintf (&ld_base, "%s", argv[c++]); | ||
234 | } | 250 | } |
235 | 251 | ||
236 | return validate_arguments (); | 252 | return validate_arguments (); |
@@ -271,8 +287,10 @@ print_help () | |||
271 | "\t-P [--pass] ... ldap password (if required)\n" | 287 | "\t-P [--pass] ... ldap password (if required)\n" |
272 | "\t-p [--port] ... ldap port (default: %d)\n" | 288 | "\t-p [--port] ... ldap port (default: %d)\n" |
273 | #ifdef HAVE_LDAP_SET_OPTION | 289 | #ifdef HAVE_LDAP_SET_OPTION |
274 | "\t-2 [--ver2] ... use ldap porotocol version 2\n" | 290 | "\t-2 [--ver2] ... use ldap protocol version 2\n" |
275 | "\t-3 [--ver3] ... use ldap porotocol version 3\n" | 291 | "\t-3 [--ver3] ... use ldap protocol version 3\n" |
292 | "\t-4 [--use-ipv4] ... use IPv4 protocol\n" | ||
293 | "\t-6 [--use-ipv6] ... use IPv6 protocol\n" | ||
276 | "\t\t(default protocol version: %d)\n" | 294 | "\t\t(default protocol version: %d)\n" |
277 | #endif | 295 | #endif |
278 | "\t-w [--warn] ... time in secs. - if the exceeds <warn> the STATE_WARNING will be returned\n" | 296 | "\t-w [--warn] ... time in secs. - if the exceeds <warn> the STATE_WARNING will be returned\n" |
@@ -292,7 +310,7 @@ print_usage () | |||
292 | ("Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n" | 310 | ("Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n" |
293 | " [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n" | 311 | " [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n" |
294 | #ifdef HAVE_LDAP_SET_OPTION | 312 | #ifdef HAVE_LDAP_SET_OPTION |
295 | " [-2|-3]\n" | 313 | " [-2|-3] [-4|-6]\n" |
296 | #endif | 314 | #endif |
297 | "(Note: all times are in seconds.)\n", progname); | 315 | "(Note: all times are in seconds.)\n", progname); |
298 | } | 316 | } |
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index dd9f19b..7562c4c 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
@@ -33,11 +33,15 @@ STATE_WARNING return values.\n"; | |||
33 | 33 | ||
34 | const char *option_summary = "\ | 34 | const char *option_summary = "\ |
35 | -H host [-p port] [-e expect] [-C command] [-f from addr]\n\ | 35 | -H host [-p port] [-e expect] [-C command] [-f from addr]\n\ |
36 | [-w warn] [-c crit] [-t timeout] [-n] [-v]"; | 36 | [-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]"; |
37 | 37 | ||
38 | const char *options = "\ | 38 | const char *options = "\ |
39 | -H, --hostname=STRING or IPADDRESS\n\ | 39 | -H, --hostname=STRING or IPADDRESS\n\ |
40 | Check server on the indicated host\n\ | 40 | Check server on the indicated host\n\ |
41 | -4, --use-ipv4\n\ | ||
42 | Use IPv4 protocol\n\ | ||
43 | -6, --use-ipv6\n\ | ||
44 | Use IPv6 protocol\n\ | ||
41 | -p, --port=INTEGER\n\ | 45 | -p, --port=INTEGER\n\ |
42 | Make connection on the indicated port (default: %d)\n\ | 46 | Make connection on the indicated port (default: %d)\n\ |
43 | -e, --expect=STRING\n\ | 47 | -e, --expect=STRING\n\ |
@@ -233,6 +237,8 @@ process_arguments (int argc, char **argv) | |||
233 | {"nocommand", required_argument, 0, 'n'}, | 237 | {"nocommand", required_argument, 0, 'n'}, |
234 | {"verbose", no_argument, 0, 'v'}, | 238 | {"verbose", no_argument, 0, 'v'}, |
235 | {"version", no_argument, 0, 'V'}, | 239 | {"version", no_argument, 0, 'V'}, |
240 | {"use-ipv4", no_argument, 0, '4'}, | ||
241 | {"use-ipv6", no_argument, 0, '6'}, | ||
236 | {"help", no_argument, 0, 'h'}, | 242 | {"help", no_argument, 0, 'h'}, |
237 | {0, 0, 0, 0} | 243 | {0, 0, 0, 0} |
238 | }; | 244 | }; |
@@ -250,7 +256,7 @@ process_arguments (int argc, char **argv) | |||
250 | } | 256 | } |
251 | 257 | ||
252 | while (1) { | 258 | while (1) { |
253 | c = getopt_long (argc, argv, "+hVvt:p:f:e:c:w:H:C:", | 259 | c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:", |
254 | long_options, &option_index); | 260 | long_options, &option_index); |
255 | 261 | ||
256 | if (c == -1 || c == EOF) | 262 | if (c == -1 || c == EOF) |
@@ -315,6 +321,16 @@ process_arguments (int argc, char **argv) | |||
315 | usage ("Time interval must be a nonnegative integer\n"); | 321 | usage ("Time interval must be a nonnegative integer\n"); |
316 | } | 322 | } |
317 | break; | 323 | break; |
324 | case '4': | ||
325 | address_family = AF_INET; | ||
326 | break; | ||
327 | case '6': | ||
328 | #ifdef USE_IPV6 | ||
329 | address_family = AF_INET6; | ||
330 | #else | ||
331 | usage ("IPv6 support not available\n"); | ||
332 | #endif | ||
333 | break; | ||
318 | case 'V': /* version */ | 334 | case 'V': /* version */ |
319 | print_revision (progname, revision); | 335 | print_revision (progname, revision); |
320 | exit (STATE_OK); | 336 | exit (STATE_OK); |