[monitoring-plugins] check_curl: made HTTP message optional
Andreas Baumann
git at monitoring-plugins.org
Sat Jun 2 13:20:14 CEST 2018
Module: monitoring-plugins
Branch: feature_check_curl
Commit: ba7a42fffc5f19a72e812dfc781113a0b202d3b8
Author: Andreas Baumann <mail at andreasbaumann.cc>
Date: Sat Jun 2 13:17:04 2018 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=ba7a42f
check_curl: made HTTP message optional
---
REQUIREMENTS | 2 +-
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:
- 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_CRETINFO with
+ 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
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:
die (STATE_CRITICAL, _("HTTP CRITICAL - No header received from host\n"));
/* get status line of answer, check sanity of HTTP code */
+ strcpy( header_buf.buf, "HTTP/1.1 200\r\nServer: unkown\r\n\r\n" );
if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) {
snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparsable status line in %.3g seconds response time|%s\n",
total_time, perfstring);
@@ -1865,7 +1866,7 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line)
char *pp;
const char *start;
char *first_line_buf;
-
+
/* find last start of a new header */
start = strrstr2 (buf, "\r\nHTTP");
if (start != NULL) {
@@ -1921,7 +1922,7 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line)
/* Human readable message: "Not Found" CRLF */
p = strtok( NULL, "" );
- if( p == NULL ) { free( status_line->first_line ); return -1; }
+ if( p == NULL ) { status_line->msg = ""; return 0; }
status_line->msg = status_line->first_line + ( p - first_line_buf );
free( first_line_buf );
More information about the Commits
mailing list