diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2018-06-02 13:17:04 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2018-06-02 13:17:04 +0200 |
commit | ba7a42fffc5f19a72e812dfc781113a0b202d3b8 (patch) | |
tree | deb1b8868b212c1e2fd1ac2f73f872bd2bc4a3cd | |
parent | b11da4d84b1323e2ba56071a85fabd5c7246d999 (diff) | |
download | monitoring-plugins-ba7a42f.tar.gz |
check_curl: made HTTP message optional
-rw-r--r-- | REQUIREMENTS | 2 | ||||
-rw-r--r-- | plugins/check_curl.c | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/REQUIREMENTS b/REQUIREMENTS index e641cea0..f04a3f0e 100644 --- a/REQUIREMENTS +++ b/REQUIREMENTS | |||
@@ -15,7 +15,7 @@ check_curl: | |||
15 | - Requires libcurl 7.15.2 or later | 15 | - Requires libcurl 7.15.2 or later |
16 | http://www.haxx.se | 16 | http://www.haxx.se |
17 | - --ssl/-S and -C requires OpenSSL for certificate checks, otherwise | 17 | - --ssl/-S and -C requires OpenSSL for certificate checks, otherwise |
18 | libcurl must be quite new to support CURLINFO_CRETINFO with | 18 | libcurl must be quite new to support CURLINFO_CERTINFO with |
19 | GnuTLS and NSS libraries: | 19 | GnuTLS and NSS libraries: |
20 | - 7.42.0 or newer for GnuTLS | 20 | - 7.42.0 or newer for GnuTLS |
21 | - 7.34.0 or newer for NSS | 21 | - 7.34.0 or newer for NSS |
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 715af431..4e65fea7 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -725,6 +725,7 @@ GOT_FIRST_CERT: | |||
725 | die (STATE_CRITICAL, _("HTTP CRITICAL - No header received from host\n")); | 725 | die (STATE_CRITICAL, _("HTTP CRITICAL - No header received from host\n")); |
726 | 726 | ||
727 | /* get status line of answer, check sanity of HTTP code */ | 727 | /* get status line of answer, check sanity of HTTP code */ |
728 | strcpy( header_buf.buf, "HTTP/1.1 200\r\nServer: unkown\r\n\r\n" ); | ||
728 | if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) { | 729 | if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) { |
729 | snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparsable status line in %.3g seconds response time|%s\n", | 730 | snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparsable status line in %.3g seconds response time|%s\n", |
730 | total_time, perfstring); | 731 | total_time, perfstring); |
@@ -1865,7 +1866,7 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line) | |||
1865 | char *pp; | 1866 | char *pp; |
1866 | const char *start; | 1867 | const char *start; |
1867 | char *first_line_buf; | 1868 | char *first_line_buf; |
1868 | 1869 | ||
1869 | /* find last start of a new header */ | 1870 | /* find last start of a new header */ |
1870 | start = strrstr2 (buf, "\r\nHTTP"); | 1871 | start = strrstr2 (buf, "\r\nHTTP"); |
1871 | if (start != NULL) { | 1872 | if (start != NULL) { |
@@ -1921,7 +1922,7 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line) | |||
1921 | /* Human readable message: "Not Found" CRLF */ | 1922 | /* Human readable message: "Not Found" CRLF */ |
1922 | 1923 | ||
1923 | p = strtok( NULL, "" ); | 1924 | p = strtok( NULL, "" ); |
1924 | if( p == NULL ) { free( status_line->first_line ); return -1; } | 1925 | if( p == NULL ) { status_line->msg = ""; return 0; } |
1925 | status_line->msg = status_line->first_line + ( p - first_line_buf ); | 1926 | status_line->msg = status_line->first_line + ( p - first_line_buf ); |
1926 | free( first_line_buf ); | 1927 | free( first_line_buf ); |
1927 | 1928 | ||