diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2018-06-02 11:17:04 (GMT) |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2018-10-22 14:30:31 (GMT) |
commit | bd7fe411d5f67b2de7d519da0575654585d1d321 (patch) | |
tree | 7d55b119ce8e1de232976eb60396a2868e9998d6 | |
parent | df5be47f84c06d2fd481439793dc86494fdc0d7a (diff) | |
download | monitoring-plugins-bd7fe411d5f67b2de7d519da0575654585d1d321.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 e641cea..f04a3f0 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 715af43..4e65fea 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 | ||