From git at monitoring-plugins.org Sat Sep 7 11:20:11 2019 From: git at monitoring-plugins.org (Andreas Baumann) Date: Sat, 7 Sep 2019 11:20:11 +0200 (CEST) Subject: [monitoring-plugins] remove obsolete AM_CONDITIONAL([WITH_CHECK_CURL]) Message-ID: <20190907092011.D945C2002465@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: feature_check_curl Commit: 0d5fe4c35e96cd6fed9eed5aefb39d386cebcc93 Author: Andreas Baumann Date: Sat Sep 7 11:19:32 2019 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=0d5fe4c remove obsolete AM_CONDITIONAL([WITH_CHECK_CURL]) --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4ce1409..267c40a 100644 --- a/configure.ac +++ b/configure.ac @@ -419,7 +419,6 @@ dnl prerequisites met, enable the plugin if test x$_can_enable_check_curl = xyes; then EXTRAS="$EXTRAS check_curl\$(EXEEXT)" fi -AM_CONDITIONAL([WITH_CHECK_CURL], [test "$_can_enable_check_curl" = "yes"]) AC_CONFIG_FILES([plugins/picohttpparser/Makefile]) dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface From git at monitoring-plugins.org Sat Sep 7 11:20:11 2019 From: git at monitoring-plugins.org (Andreas Baumann) Date: Sat, 7 Sep 2019 11:20:11 +0200 (CEST) Subject: [monitoring-plugins] setting progname of check_curl plugin to ... Message-ID: <20190907092011.E65552002466@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: feature_check_curl Commit: 4d666514f2290a5dffd60ba0c0e071e5e5626baa Author: Andreas Baumann Date: Sat Sep 7 11:20:13 2019 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=4d66651 setting progname of check_curl plugin to check_curl (at least for now) --- plugins/check_curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 637e9ba..8d8cb9f 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -32,7 +32,7 @@ * * *****************************************************************************/ -const char *progname = "check_http"; +const char *progname = "check_curl"; const char *copyright = "2006-2018"; const char *email = "devel at monitoring-plugins.org"; From git at monitoring-plugins.org Sat Sep 7 11:30:12 2019 From: git at monitoring-plugins.org (Andreas Baumann) Date: Sat, 7 Sep 2019 11:30:12 +0200 (CEST) Subject: [monitoring-plugins] Merge branch 'master' into feature_check_curl Message-ID: <20190907093012.36A4D2002466@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: feature_check_curl Commit: ea7f1fbb5c4c1097737f2f1f802e3f34fc14b3d0 Author: Andreas Baumann Date: Sat Sep 7 11:27:19 2019 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=ea7f1fb Merge branch 'master' into feature_check_curl --- From git at monitoring-plugins.org Sat Sep 7 14:30:12 2019 From: git at monitoring-plugins.org (Andreas Baumann) Date: Sat, 7 Sep 2019 14:30:12 +0200 (CEST) Subject: [monitoring-plugins] fixed whitespaces in REQUIREMENTS for check_curl ... Message-ID: <20190907123012.319A12002466@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: feature_check_curl Commit: c4d194bd2d1b350aa506f17644c5159a6130bc54 Author: Andreas Baumann Date: Sat Sep 7 14:21:14 2019 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=c4d194b fixed whitespaces in REQUIREMENTS for check_curl to fit the rest of the requrirements --- REQUIREMENTS | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/REQUIREMENTS b/REQUIREMENTS index f04a3f0..f3b1c01 100644 --- a/REQUIREMENTS +++ b/REQUIREMENTS @@ -12,20 +12,20 @@ check_ldaps, check_http --ssl, check_tcp --ssl, check_smtp --starttls http://www.openssl.org, http://www.gnu.org/software/gnutls check_curl: - - Requires libcurl 7.15.2 or later - http://www.haxx.se - - --ssl/-S and -C requires OpenSSL for certificate checks, otherwise - libcurl must be quite new to support CURLINFO_CERTINFO with - GnuTLS and NSS libraries: - - 7.42.0 or newer for GnuTLS - - 7.34.0 or newer for NSS - GnuTLS is known to create problems on some distributions with - self-signed certificate chains + - Requires libcurl 7.15.2 or later + http://www.haxx.se + - --ssl/-S and -C requires OpenSSL for certificate checks, otherwise + libcurl must be quite new to support CURLINFO_CERTINFO with + GnuTLS and NSS libraries: + - 7.42.0 or newer for GnuTLS + - 7.34.0 or newer for NSS + GnuTLS is known to create problems on some distributions with + self-signed certificate chains http://www.openssl.org, http://www.gnu.org/software/gnutls, http://www.mozilla.org/projects/security/pki/nss/, other SSL implementations are currently not supported - - uriparser 0.7.5 or later - https://uriparser.github.io/ + - uriparser 0.7.5 or later + https://uriparser.github.io/ check_fping: - Requires the fping utility distributed with SATAN. Either From git at monitoring-plugins.org Sat Sep 7 14:30:12 2019 From: git at monitoring-plugins.org (Andreas Baumann) Date: Sat, 7 Sep 2019 14:30:12 +0200 (CEST) Subject: [monitoring-plugins] check_curl: updates embedded picohttpparser to ... Message-ID: <20190907123012.3D2002002467@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: feature_check_curl Commit: fe91deb40c6ca7732c3548c75c0671f580d1c81b Author: Andreas Baumann Date: Sat Sep 7 14:22:00 2019 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=fe91deb check_curl: updates embedded picohttpparser to newest git version --- plugins/picohttpparser/picohttpparser.c | 67 ++++++++++++++++++++++----------- plugins/picohttpparser/picohttpparser.h | 2 - 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/plugins/picohttpparser/picohttpparser.c b/plugins/picohttpparser/picohttpparser.c index 6a2d872..74ccc3e 100644 --- a/plugins/picohttpparser/picohttpparser.c +++ b/plugins/picohttpparser/picohttpparser.c @@ -36,8 +36,6 @@ #endif #include "picohttpparser.h" -/* $Id: a707070d11d499609f99d09f97535642cec910a8 $ */ - #if __GNUC__ >= 3 #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) @@ -73,9 +71,9 @@ #define ADVANCE_TOKEN(tok, toklen) \ do { \ const char *tok_start = buf; \ - static const char ALIGNED(16) ranges2[] = "\000\040\177\177"; \ + static const char ALIGNED(16) ranges2[16] = "\000\040\177\177"; \ int found2; \ - buf = findchar_fast(buf, buf_end, ranges2, sizeof(ranges2) - 1, &found2); \ + buf = findchar_fast(buf, buf_end, ranges2, 4, &found2); \ if (!found2) { \ CHECK_EOF(); \ } \ @@ -138,15 +136,11 @@ static const char *get_token_to_eol(const char *buf, const char *buf_end, const const char *token_start = buf; #ifdef __SSE4_2__ - static const char ranges1[] = "\0\010" - /* allow HT */ - "\012\037" - /* allow SP and up to but not including DEL */ - "\177\177" - /* allow chars w. MSB set */ - ; + static const char ALIGNED(16) ranges1[16] = "\0\010" /* allow HT */ + "\012\037" /* allow SP and up to but not including DEL */ + "\177\177"; /* allow chars w. MSB set */ int found; - buf = findchar_fast(buf, buf_end, ranges1, sizeof(ranges1) - 1, &found); + buf = findchar_fast(buf, buf_end, ranges1, 6, &found); if (found) goto FOUND_CTL; #else @@ -325,9 +319,21 @@ static const char *parse_headers(const char *buf, const char *buf_end, struct ph headers[*num_headers].name = NULL; headers[*num_headers].name_len = 0; } - if ((buf = get_token_to_eol(buf, buf_end, &headers[*num_headers].value, &headers[*num_headers].value_len, ret)) == NULL) { + const char *value; + size_t value_len; + if ((buf = get_token_to_eol(buf, buf_end, &value, &value_len, ret)) == NULL) { return NULL; } + /* remove trailing SPs and HTABs */ + const char *value_end = value + value_len; + for (; value_end != value; --value_end) { + const char c = *(value_end - 1); + if (!(c == ' ' || c == '\t')) { + break; + } + } + headers[*num_headers].value = value; + headers[*num_headers].value_len = value_end - value; } return buf; } @@ -347,9 +353,17 @@ static const char *parse_request(const char *buf, const char *buf_end, const cha /* parse request line */ ADVANCE_TOKEN(*method, *method_len); - ++buf; + do { + ++buf; + } while (*buf == ' '); ADVANCE_TOKEN(*path, *path_len); - ++buf; + do { + ++buf; + } while (*buf == ' '); + if (*method_len == 0 || *path_len == 0) { + *ret = -1; + return NULL; + } if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) { return NULL; } @@ -402,10 +416,13 @@ static const char *parse_response(const char *buf, const char *buf_end, int *min return NULL; } /* skip space */ - if (*buf++ != ' ') { + if (*buf != ' ') { *ret = -1; return NULL; } + do { + ++buf; + } while (*buf == ' '); /* parse status code, we want at least [:digit:][:digit:][:digit:] to try to parse */ if (buf_end - buf < 4) { *ret = -2; @@ -413,13 +430,21 @@ static const char *parse_response(const char *buf, const char *buf_end, int *min } PARSE_INT_3(status); - /* skip space */ - if (*buf++ != ' ') { - *ret = -1; + /* get message includig preceding space */ + if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) { return NULL; } - /* get message */ - if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) { + if (*msg_len == 0) { + /* ok */ + } else if (**msg == ' ') { + /* remove preceding space */ + do { + ++*msg; + --*msg_len; + } while (**msg == ' '); + } else { + /* garbage found after status code */ + *ret = -1; return NULL; } diff --git a/plugins/picohttpparser/picohttpparser.h b/plugins/picohttpparser/picohttpparser.h index a8fad71..0849f84 100644 --- a/plugins/picohttpparser/picohttpparser.h +++ b/plugins/picohttpparser/picohttpparser.h @@ -33,8 +33,6 @@ #define ssize_t intptr_t #endif -/* $Id: 67fd3ee74103ada60258d8a16e868f483abcca87 $ */ - #ifdef __cplusplus extern "C" { #endif From git at monitoring-plugins.org Sat Sep 7 15:40:11 2019 From: git at monitoring-plugins.org (Andreas Baumann) Date: Sat, 7 Sep 2019 15:40:11 +0200 (CEST) Subject: [monitoring-plugins] improved curlhelp_parse_statusline to handle both ... Message-ID: <20190907134011.C7B6F2002466@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: feature_check_curl Commit: 95ee6ace094109d156286ab61d3c76709e43d642 Author: Andreas Baumann Date: Sat Sep 7 15:31:15 2019 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=95ee6ac improved curlhelp_parse_statusline to handle both HTTP/1.x and HTTP/2 --- plugins/check_curl.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 8d8cb9f..3a6f2af 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -59,7 +59,7 @@ const char *email = "devel at monitoring-plugins.org"; #define DEFAULT_BUFFER_SIZE 2048 #define DEFAULT_SERVER_URL "/" -#define HTTP_EXPECT "HTTP/1." +#define HTTP_EXPECT "HTTP/" #define DEFAULT_MAX_REDIRS 15 #define INET_ADDR_MAX_SIZE INET6_ADDRSTRLEN enum { @@ -1915,44 +1915,55 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line) status_line->first_line[first_line_len] = '\0'; first_line_buf = strdup( status_line->first_line ); - /* protocol and version: "HTTP/x.x" SP */ + /* protocol and version: "HTTP/x.x" SP or "HTTP/2" SP */ p = strtok(first_line_buf, "/"); if( p == NULL ) { free( first_line_buf ); return -1; } if( strcmp( p, "HTTP" ) != 0 ) { free( first_line_buf ); return -1; } - p = strtok( NULL, "." ); - if( p == NULL ) { free( first_line_buf ); return -1; } - status_line->http_major = (int)strtol( p, &pp, 10 ); - if( *pp != '\0' ) { free( first_line_buf ); return -1; } - p = strtok( NULL, " " ); if( p == NULL ) { free( first_line_buf ); return -1; } - status_line->http_minor = (int)strtol( p, &pp, 10 ); - if( *pp != '\0' ) { free( first_line_buf ); return -1; } + if( strchr( p, '.' ) != NULL ) { + + /* HTTP 1.x case */ + char *ppp; + ppp = strtok( p, "." ); + status_line->http_major = (int)strtol( p, &pp, 10 ); + if( *pp != '\0' ) { free( first_line_buf ); return -1; } + ppp = strtok( NULL, " " ); + status_line->http_minor = (int)strtol( p, &pp, 10 ); + if( *pp != '\0' ) { free( first_line_buf ); return -1; } + p += 4; /* 1.x SP */ + } else { + /* HTTP 2 case */ + status_line->http_major = (int)strtol( p, &pp, 10 ); + status_line->http_minor = 0; + p += 2; /* 2 SP */ + } /* status code: "404" or "404.1", then SP */ - p = strtok( NULL, " ." ); + p = strtok( p, " " ); if( p == NULL ) { free( first_line_buf ); return -1; } if( strchr( p, '.' ) != NULL ) { char *ppp; ppp = strtok( p, "." ); status_line->http_code = (int)strtol( ppp, &pp, 10 ); if( *pp != '\0' ) { free( first_line_buf ); return -1; } - ppp = strtok( NULL, "" ); status_line->http_subcode = (int)strtol( ppp, &pp, 10 ); if( *pp != '\0' ) { free( first_line_buf ); return -1; } + p += 6; /* 400.1 SP */ } else { status_line->http_code = (int)strtol( p, &pp, 10 ); status_line->http_subcode = -1; if( *pp != '\0' ) { free( first_line_buf ); return -1; } + p += 4; /* 400 SP */ } /* Human readable message: "Not Found" CRLF */ - p = strtok( NULL, "" ); + p = strtok( p, "" ); if( p == NULL ) { status_line->msg = ""; return 0; } status_line->msg = status_line->first_line + ( p - first_line_buf ); free( first_line_buf ); From git at monitoring-plugins.org Sat Sep 7 16:00:11 2019 From: git at monitoring-plugins.org (Andreas Baumann) Date: Sat, 7 Sep 2019 16:00:11 +0200 (CEST) Subject: [monitoring-plugins] added --http-version option to check_curl to ... Message-ID: <20190907140011.591F12002468@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: feature_check_curl Commit: f546041722b279d947f75523c52bd779ca6344dc Author: Andreas Baumann Date: Sat Sep 7 15:58:09 2019 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=f546041 added --http-version option to check_curl to choose HTTP version --- plugins/check_curl.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 3a6f2af..7f1f64c 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -203,6 +203,7 @@ int no_body = FALSE; int maximum_age = -1; int address_family = AF_UNSPEC; curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN; +int curl_http_version = CURL_HTTP_VERSION_NONE; int process_arguments (int, char**); void handle_curl_option_return_code (CURLcode res, const char* option); @@ -386,6 +387,9 @@ check_http (void) http_method = "GET"; handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_URL, server_url), "CURLOPT_URL"); } + + /* set HTTP protocol version */ + handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_HTTP_VERSION, curl_http_version), "CURLOPT_HTTP_VERSION"); /* set HTTP method */ if (http_method) { @@ -1085,7 +1089,8 @@ process_arguments (int argc, char **argv) enum { INVERT_REGEX = CHAR_MAX + 1, SNI_OPTION, - CA_CERT_OPTION + CA_CERT_OPTION, + HTTP_VERSION_OPTION }; int option = 0; @@ -1125,6 +1130,7 @@ process_arguments (int argc, char **argv) {"use-ipv4", no_argument, 0, '4'}, {"use-ipv6", no_argument, 0, '6'}, {"extended-perfdata", no_argument, 0, 'E'}, + {"http-version", required_argument, 0, HTTP_VERSION_OPTION}, {0, 0, 0, 0} }; @@ -1491,6 +1497,19 @@ process_arguments (int argc, char **argv) case 'E': /* show extended perfdata */ show_extended_perfdata = TRUE; break; + case HTTP_VERSION_OPTION: + curl_http_version = CURL_HTTP_VERSION_NONE; + if (strcmp (optarg, "1.0") == 0) { + curl_http_version = CURL_HTTP_VERSION_1_0; + } else if (strcmp (optarg, "1.1") == 0) { + curl_http_version = CURL_HTTP_VERSION_1_1; + } else if (strcmp (optarg, "2") == 0) { + curl_http_version = CURL_HTTP_VERSION_2_0; + } else { + fprintf (stderr, "unkown http-version parameter: %s\n", optarg); + exit (STATE_WARNING); + } + break; case '?': /* print short usage statement if args not parsable */ usage5 (); @@ -1693,6 +1712,11 @@ print_help (void) printf (" %s\n", _("curl uses CURL_FOLLOWLOCATION built into libcurl.")); printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>"); printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)")); + printf ("\n"); + printf (" %s\n", "--http-version=VERSION"); + printf (" %s\n", _("Connect via specific HTTP protocol.")); + printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)")); + printf ("\n"); printf (UT_WARN_CRIT); @@ -1776,6 +1800,7 @@ print_usage (void) printf (" [-P string] [-m :] [-4|-6] [-N] [-M ]\n"); printf (" [-A string] [-k string] [-S ] [--sni] [-C [,]]\n"); printf (" [-T ] [-j method]\n"); + printf (" [--http-version=]\n"); printf ("\n"); printf ("%s\n", _("WARNING: check_curl is experimental. Please use")); printf ("%s\n\n", _("check_http if you need a stable version.")); From git at monitoring-plugins.org Sat Sep 7 16:10:11 2019 From: git at monitoring-plugins.org (Andreas Baumann) Date: Sat, 7 Sep 2019 16:10:11 +0200 (CEST) Subject: [monitoring-plugins] some LIBCURL_VERSION checks around HTTP/2 feature Message-ID: <20190907141011.089DC200246A@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: feature_check_curl Commit: 04c58e021097d0dda4d5ebbb3c2f96e45e50ffd4 Author: Andreas Baumann Date: Sat Sep 7 16:06:17 2019 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=04c58e0 some LIBCURL_VERSION checks around HTTP/2 feature --- plugins/check_curl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 7f1f64c..9dea9c4 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -1503,8 +1503,12 @@ process_arguments (int argc, char **argv) curl_http_version = CURL_HTTP_VERSION_1_0; } else if (strcmp (optarg, "1.1") == 0) { curl_http_version = CURL_HTTP_VERSION_1_1; - } else if (strcmp (optarg, "2") == 0) { + } else if ((strcmp (optarg, "2.0") == 0) || (strcmp (optarg, "2") == 0)) { +#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0) curl_http_version = CURL_HTTP_VERSION_2_0; +#else + curl_http_version = CURL_HTTP_VERSION_NONE; +#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0) */ } else { fprintf (stderr, "unkown http-version parameter: %s\n", optarg); exit (STATE_WARNING);