diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-07 07:55:44 +0000 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2018-10-22 16:30:31 +0200 |
commit | 7eb43858db118b89d13eb71bf07b2c110edb258b (patch) | |
tree | a0e0b7fde79e33de20b8addf19c710e3dc96fd80 | |
parent | 414752ee9235833587e5b34701ba0b46a99e3a45 (diff) | |
download | monitoring-plugins-7eb43858db118b89d13eb71bf07b2c110edb258b.tar.gz |
fixed some printf bugs and switched to libcurl4-openssl for Travis tests
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | plugins/check_curl.c | 19 |
2 files changed, 11 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml index ef53b2d8..e725004f 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -55,7 +55,7 @@ install: | |||
55 | - sudo apt-get install -qq --no-install-recommends autoconf automake | 55 | - sudo apt-get install -qq --no-install-recommends autoconf automake |
56 | - sudo apt-get install -qq --no-install-recommends faketime | 56 | - sudo apt-get install -qq --no-install-recommends faketime |
57 | - sudo apt-get install -qq --no-install-recommends libmonitoring-plugin-perl | 57 | - sudo apt-get install -qq --no-install-recommends libmonitoring-plugin-perl |
58 | - sudo apt-get install -qq --no-install-recommends libcurl3-gnutls-dev | 58 | - sudo apt-get install -qq --no-install-recommends libcurl4-openssl-dev |
59 | # Trusty related dependencies (not yet provided) | 59 | # Trusty related dependencies (not yet provided) |
60 | - test "$(dpkg -l | grep -E "mysql-(client|server)-[0-9].[0-9]" | grep -c ^ii)" -gt 0 || sudo apt-get install -qq --no-install-recommends mariadb-client mariadb-server | 60 | - test "$(dpkg -l | grep -E "mysql-(client|server)-[0-9].[0-9]" | grep -c ^ii)" -gt 0 || sudo apt-get install -qq --no-install-recommends mariadb-client mariadb-server |
61 | # enable ssl apache | 61 | # enable ssl apache |
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 3ae1c4d0..6856e781 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -711,14 +711,14 @@ GOT_FIRST_CERT: | |||
711 | /* get status line of answer, check sanity of HTTP code */ | 711 | /* get status line of answer, check sanity of HTTP code */ |
712 | if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) { | 712 | if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) { |
713 | snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparseable status line in %.3g seconds response time|%s\n", | 713 | snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparseable status line in %.3g seconds response time|%s\n", |
714 | code, total_time, perfstring); | 714 | total_time, perfstring); |
715 | die (STATE_CRITICAL, "HTTP CRITICAL HTTP/1.x %d unknown - %s", code, msg); | 715 | die (STATE_CRITICAL, "HTTP CRITICAL HTTP/1.x %ld unknown - %s", code, msg); |
716 | } | 716 | } |
717 | 717 | ||
718 | /* get result code from cURL */ | 718 | /* get result code from cURL */ |
719 | handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &code), "CURLINFO_RESPONSE_CODE"); | 719 | handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &code), "CURLINFO_RESPONSE_CODE"); |
720 | if (verbose>=2) | 720 | if (verbose>=2) |
721 | printf ("* curl CURLINFO_RESPONSE_CODE is %d\n", code); | 721 | printf ("* curl CURLINFO_RESPONSE_CODE is %ld\n", code); |
722 | 722 | ||
723 | /* print status line, header, body if verbose */ | 723 | /* print status line, header, body if verbose */ |
724 | if (verbose >= 2) { | 724 | if (verbose >= 2) { |
@@ -942,7 +942,7 @@ redir (curlhelp_write_curlbuf* header_buf) | |||
942 | 942 | ||
943 | if (++redir_depth > max_depth) | 943 | if (++redir_depth > max_depth) |
944 | die (STATE_WARNING, | 944 | die (STATE_WARNING, |
945 | _("HTTP WARNING - maximum redirection depth %d exceeded - %s\n"), | 945 | _("HTTP WARNING - maximum redirection depth %d exceeded - %s%s\n"), |
946 | max_depth, location, (display_html ? "</A>" : "")); | 946 | max_depth, location, (display_html ? "</A>" : "")); |
947 | 947 | ||
948 | UriParserStateA state; | 948 | UriParserStateA state; |
@@ -1005,7 +1005,7 @@ redir (curlhelp_write_curlbuf* header_buf) | |||
1005 | } | 1005 | } |
1006 | if (new_port > MAX_PORT) | 1006 | if (new_port > MAX_PORT) |
1007 | die (STATE_UNKNOWN, | 1007 | die (STATE_UNKNOWN, |
1008 | _("HTTP UNKNOWN - Redirection to port above %d - %s\n"), | 1008 | _("HTTP UNKNOWN - Redirection to port above %d - %s%s\n"), |
1009 | MAX_PORT, location, display_html ? "</A>" : ""); | 1009 | MAX_PORT, location, display_html ? "</A>" : ""); |
1010 | 1010 | ||
1011 | /* by RFC 7231 relative URLs in Location should be taken relative to | 1011 | /* by RFC 7231 relative URLs in Location should be taken relative to |
@@ -1239,7 +1239,8 @@ process_arguments (int argc, char **argv) | |||
1239 | http_method = strdup (optarg); | 1239 | http_method = strdup (optarg); |
1240 | break; | 1240 | break; |
1241 | case 'A': /* useragent */ | 1241 | case 'A': /* useragent */ |
1242 | snprintf (user_agent, DEFAULT_BUFFER_SIZE, optarg); | 1242 | strncpy (user_agent, optarg, DEFAULT_BUFFER_SIZE); |
1243 | user_agent[DEFAULT_BUFFER_SIZE-1] = '\0'; | ||
1243 | break; | 1244 | break; |
1244 | case 'k': /* Additional headers */ | 1245 | case 'k': /* Additional headers */ |
1245 | if (http_opt_headers_count == 0) | 1246 | if (http_opt_headers_count == 0) |
@@ -1524,7 +1525,7 @@ process_arguments (int argc, char **argv) | |||
1524 | if (critical_thresholds && thlds->critical->end>(double)socket_timeout) | 1525 | if (critical_thresholds && thlds->critical->end>(double)socket_timeout) |
1525 | socket_timeout = (int)thlds->critical->end + 1; | 1526 | socket_timeout = (int)thlds->critical->end + 1; |
1526 | if (verbose >= 2) | 1527 | if (verbose >= 2) |
1527 | printf ("* Socket timeout set to %d seconds\n", socket_timeout); | 1528 | printf ("* Socket timeout set to %ld seconds\n", socket_timeout); |
1528 | 1529 | ||
1529 | if (http_method == NULL) | 1530 | if (http_method == NULL) |
1530 | http_method = strdup ("GET"); | 1531 | http_method = strdup ("GET"); |
@@ -1722,7 +1723,7 @@ print_usage (void) | |||
1722 | printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); | 1723 | printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); |
1723 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); | 1724 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); |
1724 | printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]\n"); | 1725 | printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]\n"); |
1725 | printf (" [-T <content-type>] [-j method]\n", progname); | 1726 | printf (" [-T <content-type>] [-j method]\n"); |
1726 | printf ("\n"); | 1727 | printf ("\n"); |
1727 | printf ("%s\n", _("WARNING: check_curl is experimental. Please use")); | 1728 | printf ("%s\n", _("WARNING: check_curl is experimental. Please use")); |
1728 | printf ("%s\n\n", _("check_http if you need a stable version.")); | 1729 | printf ("%s\n\n", _("check_http if you need a stable version.")); |
@@ -1969,7 +1970,7 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA | |||
1969 | time_t srv_data = curl_getdate (server_date, NULL); | 1970 | time_t srv_data = curl_getdate (server_date, NULL); |
1970 | time_t doc_data = curl_getdate (document_date, NULL); | 1971 | time_t doc_data = curl_getdate (document_date, NULL); |
1971 | if (verbose >= 2) | 1972 | if (verbose >= 2) |
1972 | printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, srv_data, document_date, doc_data); | 1973 | printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, document_date, (int)doc_data); |
1973 | if (srv_data <= 0) { | 1974 | if (srv_data <= 0) { |
1974 | snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date); | 1975 | snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date); |
1975 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 1976 | date_result = max_state_alt(STATE_CRITICAL, date_result); |