diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-01-09 13:54:12 (GMT) |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-01-09 13:54:12 (GMT) |
commit | adb958849491ea7e0bba4a15896ebd41a0fbff2d (patch) | |
tree | 837f51cfb28406519481a959e5a484f188c0e2cb | |
parent | 5e0c236d6a3499f08b16a2ddb5147393e9dbd27a (diff) | |
parent | f53ea7afd8e124690871ebdb79a1432e4dd14488 (diff) | |
download | monitoring-plugins-adb958849491ea7e0bba4a15896ebd41a0fbff2d.tar.gz |
Merge branch 'master' into feature_check_curl
-rw-r--r-- | plugins/check_tcp.c | 23 | ||||
-rw-r--r-- | plugins/popen.c | 4 | ||||
-rw-r--r-- | plugins/popen.h | 1 |
3 files changed, 23 insertions, 5 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 61333bd..1365b9c 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
@@ -86,6 +86,11 @@ static char buffer[MAXBUF]; | |||
86 | static int expect_mismatch_state = STATE_WARNING; | 86 | static int expect_mismatch_state = STATE_WARNING; |
87 | static int match_flags = NP_MATCH_EXACT; | 87 | static int match_flags = NP_MATCH_EXACT; |
88 | 88 | ||
89 | #ifdef HAVE_SSL | ||
90 | static char *sni = NULL; | ||
91 | static int sni_specified = FALSE; | ||
92 | #endif | ||
93 | |||
89 | #define FLAG_SSL 0x01 | 94 | #define FLAG_SSL 0x01 |
90 | #define FLAG_VERBOSE 0x02 | 95 | #define FLAG_VERBOSE 0x02 |
91 | #define FLAG_TIME_WARN 0x04 | 96 | #define FLAG_TIME_WARN 0x04 |
@@ -241,7 +246,7 @@ main (int argc, char **argv) | |||
241 | 246 | ||
242 | #ifdef HAVE_SSL | 247 | #ifdef HAVE_SSL |
243 | if (flags & FLAG_SSL){ | 248 | if (flags & FLAG_SSL){ |
244 | result = np_net_ssl_init(sd); | 249 | result = np_net_ssl_init_with_hostname(sd, (sni_specified ? sni : NULL)); |
245 | if (result == STATE_OK && check_cert == TRUE) { | 250 | if (result == STATE_OK && check_cert == TRUE) { |
246 | result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); | 251 | result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); |
247 | } | 252 | } |
@@ -401,6 +406,10 @@ process_arguments (int argc, char **argv) | |||
401 | int escape = 0; | 406 | int escape = 0; |
402 | char *temp; | 407 | char *temp; |
403 | 408 | ||
409 | enum { | ||
410 | SNI_OPTION = CHAR_MAX + 1 | ||
411 | }; | ||
412 | |||
404 | int option = 0; | 413 | int option = 0; |
405 | static struct option longopts[] = { | 414 | static struct option longopts[] = { |
406 | {"hostname", required_argument, 0, 'H'}, | 415 | {"hostname", required_argument, 0, 'H'}, |
@@ -427,6 +436,7 @@ process_arguments (int argc, char **argv) | |||
427 | {"version", no_argument, 0, 'V'}, | 436 | {"version", no_argument, 0, 'V'}, |
428 | {"help", no_argument, 0, 'h'}, | 437 | {"help", no_argument, 0, 'h'}, |
429 | {"ssl", no_argument, 0, 'S'}, | 438 | {"ssl", no_argument, 0, 'S'}, |
439 | {"sni", required_argument, 0, SNI_OPTION}, | ||
430 | {"certificate", required_argument, 0, 'D'}, | 440 | {"certificate", required_argument, 0, 'D'}, |
431 | {0, 0, 0, 0} | 441 | {0, 0, 0, 0} |
432 | }; | 442 | }; |
@@ -604,6 +614,15 @@ process_arguments (int argc, char **argv) | |||
604 | die (STATE_UNKNOWN, _("Invalid option - SSL is not available")); | 614 | die (STATE_UNKNOWN, _("Invalid option - SSL is not available")); |
605 | #endif | 615 | #endif |
606 | break; | 616 | break; |
617 | case SNI_OPTION: | ||
618 | #ifdef HAVE_SSL | ||
619 | flags |= FLAG_SSL; | ||
620 | sni_specified = TRUE; | ||
621 | sni = optarg; | ||
622 | #else | ||
623 | die (STATE_UNKNOWN, _("Invalid option - SSL is not available")); | ||
624 | #endif | ||
625 | break; | ||
607 | case 'A': | 626 | case 'A': |
608 | match_flags |= NP_MATCH_ALL; | 627 | match_flags |= NP_MATCH_ALL; |
609 | break; | 628 | break; |
@@ -671,6 +690,8 @@ print_help (void) | |||
671 | printf (" %s\n", _("1st is #days for warning, 2nd is critical (if not specified - 0).")); | 690 | printf (" %s\n", _("1st is #days for warning, 2nd is critical (if not specified - 0).")); |
672 | printf (" %s\n", "-S, --ssl"); | 691 | printf (" %s\n", "-S, --ssl"); |
673 | printf (" %s\n", _("Use SSL for the connection.")); | 692 | printf (" %s\n", _("Use SSL for the connection.")); |
693 | printf (" %s\n", "--sni=STRING"); | ||
694 | printf (" %s\n", _("SSL server_name")); | ||
674 | #endif | 695 | #endif |
675 | 696 | ||
676 | printf (UT_WARN_CRIT); | 697 | printf (UT_WARN_CRIT); |
diff --git a/plugins/popen.c b/plugins/popen.c index 557fb44..9eb49b6 100644 --- a/plugins/popen.c +++ b/plugins/popen.c | |||
@@ -39,9 +39,9 @@ | |||
39 | *****************************************************************************/ | 39 | *****************************************************************************/ |
40 | 40 | ||
41 | #include "common.h" | 41 | #include "common.h" |
42 | #include "utils.h" | ||
42 | 43 | ||
43 | /* 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 */ |
44 | extern int timeout_interval; | ||
45 | extern pid_t *childpid; | 45 | extern pid_t *childpid; |
46 | extern int *child_stderr_array; | 46 | extern int *child_stderr_array; |
47 | extern FILE *child_process; | 47 | extern FILE *child_process; |
@@ -76,8 +76,6 @@ RETSIGTYPE popen_timeout_alarm_handler (int); | |||
76 | #define SIG_ERR ((Sigfunc *)-1) | 76 | #define SIG_ERR ((Sigfunc *)-1) |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | #define min(a,b) ((a) < (b) ? (a) : (b)) | ||
80 | #define max(a,b) ((a) > (b) ? (a) : (b)) | ||
81 | 79 | ||
82 | char *pname = NULL; /* caller can set this from argv[0] */ | 80 | char *pname = NULL; /* caller can set this from argv[0] */ |
83 | 81 | ||
diff --git a/plugins/popen.h b/plugins/popen.h index fc7e78e..a5dd8fa 100644 --- a/plugins/popen.h +++ b/plugins/popen.h | |||
@@ -7,7 +7,6 @@ FILE *spopen (const char *); | |||
7 | int spclose (FILE *); | 7 | int spclose (FILE *); |
8 | RETSIGTYPE popen_timeout_alarm_handler (int); | 8 | RETSIGTYPE popen_timeout_alarm_handler (int); |
9 | 9 | ||
10 | extern unsigned int timeout_interval; | ||
11 | pid_t *childpid=NULL; | 10 | pid_t *childpid=NULL; |
12 | int *child_stderr_array=NULL; | 11 | int *child_stderr_array=NULL; |
13 | FILE *child_process=NULL; | 12 | FILE *child_process=NULL; |