summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.c
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2022-11-25 09:30:05 (GMT)
committerGitHub <noreply@github.com>2022-11-25 09:30:05 (GMT)
commit917dba07fded8ef04967183a4c0443b5cce2db82 (patch)
treebd3017f225186b3e7f29db257f0d3b5790846ff2 /plugins/check_curl.c
parent4ff0dfa44306c4e8a7dc46fcb1c508f7a191638b (diff)
parent1bc6d81651c5b5fe865515d420fc2772f4997059 (diff)
downloadmonitoring-plugins-917dba07fded8ef04967183a4c0443b5cce2db82.tar.gz
Merge branch 'master' into dev/check_ssh-patches
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r--plugins/check_curl.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index a69854a..2ad373c 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -476,6 +476,18 @@ check_http (void)
476 printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache); 476 printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache);
477 } 477 }
478 478
479 // If server_address is an IPv6 address it must be surround by square brackets
480 struct in6_addr tmp_in_addr;
481 if (inet_pton(AF_INET6, server_address, &tmp_in_addr) == 1) {
482 char *new_server_address = malloc(strlen(server_address) + 3);
483 if (new_server_address == NULL) {
484 die(STATE_UNKNOWN, "HTTP UNKNOWN - Unable to allocate memory\n");
485 }
486 snprintf(new_server_address, strlen(server_address)+3, "[%s]", server_address);
487 free(server_address);
488 server_address = new_server_address;
489 }
490
479 /* compose URL: use the address we want to connect to, set Host: header later */ 491 /* compose URL: use the address we want to connect to, set Host: header later */
480 snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s", 492 snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
481 use_ssl ? "https" : "http", 493 use_ssl ? "https" : "http",
@@ -999,10 +1011,12 @@ GOT_FIRST_CERT:
999 result = max_state_alt(get_status(total_time, thlds), result); 1011 result = max_state_alt(get_status(total_time, thlds), result);
1000 1012
1001 /* Cut-off trailing characters */ 1013 /* Cut-off trailing characters */
1002 if(msg[strlen(msg)-2] == ',') 1014 if (strlen(msg) >= 2) {
1003 msg[strlen(msg)-2] = '\0'; 1015 if(msg[strlen(msg)-2] == ',')
1004 else 1016 msg[strlen(msg)-2] = '\0';
1005 msg[strlen(msg)-3] = '\0'; 1017 else
1018 msg[strlen(msg)-3] = '\0';
1019 }
1006 1020
1007 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ 1021 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
1008 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s", 1022 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",