mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-05-28 04:35:40 -04:00
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
This commit is contained in:
parent
97634d8fc6
commit
f813c747a2
3 changed files with 60 additions and 10 deletions
|
|
@ -45,13 +45,17 @@ certificate expiration times.\n"
|
|||
[-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
|
||||
[-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
|
||||
[-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
|
||||
[-P string] [-m min_pg_size]"
|
||||
[-P string] [-m min_pg_size] [-4|-6]"
|
||||
|
||||
#define LONGOPTIONS "\
|
||||
-H, --hostname=ADDRESS\n\
|
||||
Host name argument for servers using host headers (virtual host)\n\
|
||||
-I, --IP-address=ADDRESS\n\
|
||||
IP address or name (use numeric address if possible to bypass DNS lookup).\n\
|
||||
-4, --use-ipv4\n\
|
||||
Use IPv4 protocol\n\
|
||||
-6, --use-ipv6\n\
|
||||
Use IPv6 protocol\n\
|
||||
-e, --expect=STRING\n\
|
||||
String to expect in first (status) line of server response (default: %s)\n\
|
||||
If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)\n\
|
||||
|
|
@ -316,6 +320,8 @@ process_arguments (int argc, char **argv)
|
|||
{"onredirect", required_argument, 0, 'f'},
|
||||
{"certificate", required_argument, 0, 'C'},
|
||||
{"min", required_argument, 0, 'm'},
|
||||
{"use-ipv4", no_argument, 0, '4'},
|
||||
{"use-ipv6", no_argument, 0, '6'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
|
@ -336,7 +342,7 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
while (1) {
|
||||
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);
|
||||
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);
|
||||
if (c == -1 || c == EOF)
|
||||
break;
|
||||
|
||||
|
|
@ -464,6 +470,16 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
break;
|
||||
#endif
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
case '6':
|
||||
#ifdef USE_IPV6
|
||||
address_family = AF_INET6;
|
||||
#else
|
||||
usage ("IPv6 support not available\n");
|
||||
#endif
|
||||
break;
|
||||
case 'v': /* verbose */
|
||||
verbose = TRUE;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ process_arguments (int argc, char **argv)
|
|||
{"ver2", no_argument, 0, '2'},
|
||||
{"ver3", no_argument, 0, '3'},
|
||||
#endif
|
||||
{"use-ipv4", no_argument, 0, '4'},
|
||||
{"use-ipv6", no_argument, 0, '6'},
|
||||
{"port", required_argument, 0, 'p'},
|
||||
{"warn", required_argument, 0, 'w'},
|
||||
{"crit", required_argument, 0, 'c'},
|
||||
|
|
@ -174,7 +176,7 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "hV23t:c:w:H:b:p:a:D:P:", longopts, &option_index);
|
||||
c = getopt_long (argc, argv, "hV2346t:c:w:H:b:p:a:D:P:", longopts, &option_index);
|
||||
|
||||
if (c == -1 || c == EOF)
|
||||
break;
|
||||
|
|
@ -223,14 +225,28 @@ process_arguments (int argc, char **argv)
|
|||
ld_protocol = 3;
|
||||
break;
|
||||
#endif
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
case '6':
|
||||
#ifdef USE_IPV6
|
||||
address_family = AF_INET6;
|
||||
#else
|
||||
usage ("IPv6 support not available\n");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
usage ("check_ldap: could not parse unknown arguments\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ld_host[0] == 0) {
|
||||
asprintf (&ld_host, "%s", argv[c]);
|
||||
c = optind;
|
||||
if (strlen(ld_host) == 0 && is_host(argv[c])) {
|
||||
asprintf (&ld_host, "%s", argv[c++]);
|
||||
}
|
||||
if (strlen(ld_base) == 0 && argv[c]) {
|
||||
asprintf (&ld_base, "%s", argv[c++]);
|
||||
}
|
||||
|
||||
return validate_arguments ();
|
||||
|
|
@ -271,8 +287,10 @@ print_help ()
|
|||
"\t-P [--pass] ... ldap password (if required)\n"
|
||||
"\t-p [--port] ... ldap port (default: %d)\n"
|
||||
#ifdef HAVE_LDAP_SET_OPTION
|
||||
"\t-2 [--ver2] ... use ldap porotocol version 2\n"
|
||||
"\t-3 [--ver3] ... use ldap porotocol version 3\n"
|
||||
"\t-2 [--ver2] ... use ldap protocol version 2\n"
|
||||
"\t-3 [--ver3] ... use ldap protocol version 3\n"
|
||||
"\t-4 [--use-ipv4] ... use IPv4 protocol\n"
|
||||
"\t-6 [--use-ipv6] ... use IPv6 protocol\n"
|
||||
"\t\t(default protocol version: %d)\n"
|
||||
#endif
|
||||
"\t-w [--warn] ... time in secs. - if the exceeds <warn> the STATE_WARNING will be returned\n"
|
||||
|
|
@ -292,7 +310,7 @@ print_usage ()
|
|||
("Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n"
|
||||
" [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n"
|
||||
#ifdef HAVE_LDAP_SET_OPTION
|
||||
" [-2|-3]\n"
|
||||
" [-2|-3] [-4|-6]\n"
|
||||
#endif
|
||||
"(Note: all times are in seconds.)\n", progname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,11 +33,15 @@ STATE_WARNING return values.\n";
|
|||
|
||||
const char *option_summary = "\
|
||||
-H host [-p port] [-e expect] [-C command] [-f from addr]\n\
|
||||
[-w warn] [-c crit] [-t timeout] [-n] [-v]";
|
||||
[-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]";
|
||||
|
||||
const char *options = "\
|
||||
-H, --hostname=STRING or IPADDRESS\n\
|
||||
Check server on the indicated host\n\
|
||||
-4, --use-ipv4\n\
|
||||
Use IPv4 protocol\n\
|
||||
-6, --use-ipv6\n\
|
||||
Use IPv6 protocol\n\
|
||||
-p, --port=INTEGER\n\
|
||||
Make connection on the indicated port (default: %d)\n\
|
||||
-e, --expect=STRING\n\
|
||||
|
|
@ -233,6 +237,8 @@ process_arguments (int argc, char **argv)
|
|||
{"nocommand", required_argument, 0, 'n'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{"use-ipv4", no_argument, 0, '4'},
|
||||
{"use-ipv6", no_argument, 0, '6'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
|
@ -250,7 +256,7 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "+hVvt:p:f:e:c:w:H:C:",
|
||||
c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:",
|
||||
long_options, &option_index);
|
||||
|
||||
if (c == -1 || c == EOF)
|
||||
|
|
@ -315,6 +321,16 @@ process_arguments (int argc, char **argv)
|
|||
usage ("Time interval must be a nonnegative integer\n");
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
case '6':
|
||||
#ifdef USE_IPV6
|
||||
address_family = AF_INET6;
|
||||
#else
|
||||
usage ("IPv6 support not available\n");
|
||||
#endif
|
||||
break;
|
||||
case 'V': /* version */
|
||||
print_revision (progname, revision);
|
||||
exit (STATE_OK);
|
||||
|
|
|
|||
Loading…
Reference in a new issue