summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r--plugins/check_curl.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 3d368c1..20ac5b7 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -332,15 +332,15 @@ check_http (void)
332 /* no-body */ 332 /* no-body */
333 if (no_body) 333 if (no_body)
334 curl_easy_setopt (curl, CURLOPT_NOBODY, 1); 334 curl_easy_setopt (curl, CURLOPT_NOBODY, 1);
335 335
336 /* IPv4 or IPv6 forced DNS resolution */ 336 /* IPv4 or IPv6 forced DNS resolution */
337 if (address_family == AF_UNSPEC) 337 if (address_family == AF_UNSPEC)
338 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER); 338 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
339 else if (address_family == AF_INET) 339 else if (address_family == AF_INET)
340 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); 340 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
341 else if (address_family == AF_INET6) 341 else if (address_family == AF_INET6)
342 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); 342 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
343 343
344 /* do the request */ 344 /* do the request */
345 res = curl_easy_perform(curl); 345 res = curl_easy_perform(curl);
346 346
@@ -466,9 +466,9 @@ check_http (void)
466 } 466 }
467 else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) { 467 else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) {
468 if (invert_regex == 0) 468 if (invert_regex == 0)
469 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern not found"), msg); 469 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg);
470 else 470 else
471 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern found"), msg); 471 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg);
472 result = STATE_CRITICAL; 472 result = STATE_CRITICAL;
473 } 473 }
474 else { 474 else {
@@ -495,11 +495,18 @@ check_http (void)
495 /* -w, -c: check warning and critical level */ 495 /* -w, -c: check warning and critical level */
496 result = max_state_alt(get_status(total_time, thlds), result); 496 result = max_state_alt(get_status(total_time, thlds), result);
497 497
498 /* Cut-off trailing characters */
499 if(msg[strlen(msg)-2] == ',')
500 msg[strlen(msg)-2] = '\0';
501 else
502 msg[strlen(msg)-3] = '\0';
503
498 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ 504 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
499 die (result, "HTTP %s HTTP/%d.%d %d %s - %s - %.3g seconds response time|%s\n", 505 die (result, "HTTP %s: HTTP/%d.%d %d %s%s%s - %d bytes in %.3f second response time |%s\n",
500 state_text(result), status_line.http_major, status_line.http_minor, 506 state_text(result), status_line.http_major, status_line.http_minor,
501 status_line.http_code, status_line.msg, msg, 507 status_line.http_code, status_line.msg,
502 total_time, perfstring); 508 strlen(msg) > 0 ? " - " : "",
509 msg, page_len, total_time, perfstring);
503 510
504 /* proper cleanup after die? */ 511 /* proper cleanup after die? */
505 curlhelp_free_statusline(&status_line); 512 curlhelp_free_statusline(&status_line);