diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-09-12 16:37:24 +0200 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-09-12 16:37:24 +0200 |
commit | 44b2a25a6b9fb0791ec7150100a4d51e5f129611 (patch) | |
tree | 4fb13f9effac32bf156cc6eaefe22f6deea6d7ea /plugins/check_curl.d | |
parent | aaff3aa9da27ff7666d2a776d524c784b76eb3d7 (diff) | |
download | monitoring-plugins-44b2a25a6b9fb0791ec7150100a4d51e5f129611.tar.gz |
check_curl: implement new output mechanism
Diffstat (limited to 'plugins/check_curl.d')
-rw-r--r-- | plugins/check_curl.d/check_curl_helpers.c | 251 | ||||
-rw-r--r-- | plugins/check_curl.d/check_curl_helpers.h | 21 | ||||
-rw-r--r-- | plugins/check_curl.d/config.h | 7 |
3 files changed, 163 insertions, 116 deletions
diff --git a/plugins/check_curl.d/check_curl_helpers.c b/plugins/check_curl.d/check_curl_helpers.c index e33f2aa9..49949ccb 100644 --- a/plugins/check_curl.d/check_curl_helpers.c +++ b/plugins/check_curl.d/check_curl_helpers.c | |||
@@ -5,9 +5,12 @@ | |||
5 | #include <netdb.h> | 5 | #include <netdb.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include "../utils.h" | 7 | #include "../utils.h" |
8 | #include "check_curl.d/config.h" | ||
9 | #include "output.h" | ||
10 | #include "perfdata.h" | ||
11 | #include "states.h" | ||
8 | 12 | ||
9 | extern int verbose; | 13 | extern int verbose; |
10 | char msg[DEFAULT_BUFFER_SIZE]; | ||
11 | char errbuf[MAX_INPUT_BUFFER]; | 14 | char errbuf[MAX_INPUT_BUFFER]; |
12 | bool is_openssl_callback = false; | 15 | bool is_openssl_callback = false; |
13 | bool add_sslctx_verify_fun = false; | 16 | bool add_sslctx_verify_fun = false; |
@@ -127,10 +130,9 @@ check_curl_configure_curl(const check_curl_static_curl_config config, | |||
127 | int res; | 130 | int res; |
128 | if ((res = lookup_host(working_state.server_address, addrstr, DEFAULT_BUFFER_SIZE / 2, | 131 | if ((res = lookup_host(working_state.server_address, addrstr, DEFAULT_BUFFER_SIZE / 2, |
129 | config.sin_family)) != 0) { | 132 | config.sin_family)) != 0) { |
130 | snprintf(msg, DEFAULT_BUFFER_SIZE, | 133 | die(STATE_CRITICAL, |
131 | _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"), | 134 | _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"), |
132 | working_state.server_address, res, gai_strerror(res)); | 135 | working_state.server_address, res, gai_strerror(res)); |
133 | die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); | ||
134 | } | 136 | } |
135 | snprintf(dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", working_state.host_name, | 137 | snprintf(dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", working_state.host_name, |
136 | working_state.serverPort, addrstr); | 138 | working_state.serverPort, addrstr); |
@@ -154,12 +156,7 @@ check_curl_configure_curl(const check_curl_static_curl_config config, | |||
154 | } | 156 | } |
155 | 157 | ||
156 | /* compose URL: use the address we want to connect to, set Host: header later */ | 158 | /* compose URL: use the address we want to connect to, set Host: header later */ |
157 | char url[DEFAULT_BUFFER_SIZE]; | 159 | char *url = fmt_url(working_state); |
158 | snprintf(url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s", working_state.use_ssl ? "https" : "http", | ||
159 | (working_state.use_ssl & (working_state.host_name != NULL)) | ||
160 | ? working_state.host_name | ||
161 | : working_state.server_address, | ||
162 | working_state.serverPort, working_state.server_url); | ||
163 | 160 | ||
164 | if (verbose >= 1) { | 161 | if (verbose >= 1) { |
165 | printf("* curl CURLOPT_URL: %s\n", url); | 162 | printf("* curl CURLOPT_URL: %s\n", url); |
@@ -167,6 +164,8 @@ check_curl_configure_curl(const check_curl_static_curl_config config, | |||
167 | handle_curl_option_return_code(curl_easy_setopt(result.curl_state.curl, CURLOPT_URL, url), | 164 | handle_curl_option_return_code(curl_easy_setopt(result.curl_state.curl, CURLOPT_URL, url), |
168 | "CURLOPT_URL"); | 165 | "CURLOPT_URL"); |
169 | 166 | ||
167 | free(url); | ||
168 | |||
170 | /* extract proxy information for legacy proxy https requests */ | 169 | /* extract proxy information for legacy proxy https requests */ |
171 | if (!strcmp(working_state.http_method, "CONNECT") || | 170 | if (!strcmp(working_state.http_method, "CONNECT") || |
172 | strstr(working_state.server_url, "http") == working_state.server_url) { | 171 | strstr(working_state.server_url, "http") == working_state.server_url) { |
@@ -548,10 +547,8 @@ check_curl_configure_curl(const check_curl_static_curl_config config, | |||
548 | 547 | ||
549 | void handle_curl_option_return_code(CURLcode res, const char *option) { | 548 | void handle_curl_option_return_code(CURLcode res, const char *option) { |
550 | if (res != CURLE_OK) { | 549 | if (res != CURLE_OK) { |
551 | snprintf(msg, DEFAULT_BUFFER_SIZE, | 550 | die(STATE_CRITICAL, _("Error while setting cURL option '%s': cURL returned %d - %s"), |
552 | _("Error while setting cURL option '%s': cURL returned %d - %s"), option, res, | 551 | option, res, curl_easy_strerror(res)); |
553 | curl_easy_strerror(res)); | ||
554 | die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); | ||
555 | } | 552 | } |
556 | } | 553 | } |
557 | 554 | ||
@@ -618,9 +615,9 @@ check_curl_config check_curl_config_init() { | |||
618 | .continue_after_check_cert = false, | 615 | .continue_after_check_cert = false, |
619 | .days_till_exp_warn = 0, | 616 | .days_till_exp_warn = 0, |
620 | .days_till_exp_crit = 0, | 617 | .days_till_exp_crit = 0, |
621 | .thlds = NULL, | 618 | .thlds = mp_thresholds_init(), |
622 | .min_page_len = 0, | 619 | .page_length_limits = mp_range_init(), |
623 | .max_page_len = 0, | 620 | .page_length_limits_is_set = false, |
624 | .server_expect = | 621 | .server_expect = |
625 | { | 622 | { |
626 | .string = HTTP_EXPECT, | 623 | .string = HTTP_EXPECT, |
@@ -729,9 +726,7 @@ size_t get_content_length(const curlhelp_write_curlbuf *header_buf, | |||
729 | return header_buf->buflen + body_buf->buflen; | 726 | return header_buf->buflen + body_buf->buflen; |
730 | } | 727 | } |
731 | 728 | ||
732 | mp_state_enum check_document_dates(const curlhelp_write_curlbuf *header_buf, | 729 | mp_subcheck check_document_dates(const curlhelp_write_curlbuf *header_buf, const int maximum_age) { |
733 | const char msg[static DEFAULT_BUFFER_SIZE], | ||
734 | const int maximum_age) { | ||
735 | struct phr_header headers[255]; | 730 | struct phr_header headers[255]; |
736 | size_t nof_headers = 255; | 731 | size_t nof_headers = 255; |
737 | curlhelp_statusline status_line; | 732 | curlhelp_statusline status_line; |
@@ -747,73 +742,54 @@ mp_state_enum check_document_dates(const curlhelp_write_curlbuf *header_buf, | |||
747 | char *server_date = get_header_value(headers, nof_headers, "date"); | 742 | char *server_date = get_header_value(headers, nof_headers, "date"); |
748 | char *document_date = get_header_value(headers, nof_headers, "last-modified"); | 743 | char *document_date = get_header_value(headers, nof_headers, "last-modified"); |
749 | 744 | ||
750 | mp_state_enum date_result = STATE_OK; | 745 | mp_subcheck sc_document_dates = mp_subcheck_init(); |
751 | if (!server_date || !*server_date) { | 746 | if (!server_date || !*server_date) { |
752 | char tmp[DEFAULT_BUFFER_SIZE]; | 747 | xasprintf(&sc_document_dates.output, _("Server date unknown")); |
753 | 748 | sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_UNKNOWN); | |
754 | snprintf(tmp, DEFAULT_BUFFER_SIZE, _("%sServer date unknown, "), msg); | ||
755 | strcpy(msg, tmp); | ||
756 | |||
757 | date_result = max_state_alt(STATE_UNKNOWN, date_result); | ||
758 | |||
759 | } else if (!document_date || !*document_date) { | 749 | } else if (!document_date || !*document_date) { |
760 | char tmp[DEFAULT_BUFFER_SIZE]; | 750 | xasprintf(&sc_document_dates.output, _("Document modification date unknown, ")); |
761 | 751 | sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_CRITICAL); | |
762 | snprintf(tmp, DEFAULT_BUFFER_SIZE, _("%sDocument modification date unknown, "), msg); | ||
763 | strcpy(msg, tmp); | ||
764 | |||
765 | date_result = max_state_alt(STATE_CRITICAL, date_result); | ||
766 | |||
767 | } else { | 752 | } else { |
768 | time_t srv_data = curl_getdate(server_date, NULL); | 753 | time_t srv_data = curl_getdate(server_date, NULL); |
769 | time_t doc_data = curl_getdate(document_date, NULL); | 754 | time_t doc_data = curl_getdate(document_date, NULL); |
755 | |||
770 | if (verbose >= 2) { | 756 | if (verbose >= 2) { |
771 | printf("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, | 757 | printf("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, |
772 | document_date, (int)doc_data); | 758 | document_date, (int)doc_data); |
773 | } | 759 | } |
774 | if (srv_data <= 0) { | ||
775 | char tmp[DEFAULT_BUFFER_SIZE]; | ||
776 | 760 | ||
777 | snprintf(tmp, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), msg, | 761 | if (srv_data <= 0) { |
778 | server_date); | 762 | xasprintf(&sc_document_dates.output, _("Server date \"%100s\" unparsable"), |
779 | strcpy(msg, tmp); | 763 | server_date); |
780 | 764 | sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_CRITICAL); | |
781 | date_result = max_state_alt(STATE_CRITICAL, date_result); | ||
782 | } else if (doc_data <= 0) { | 765 | } else if (doc_data <= 0) { |
783 | char tmp[DEFAULT_BUFFER_SIZE]; | ||
784 | |||
785 | snprintf(tmp, DEFAULT_BUFFER_SIZE, _("%sDocument date \"%100s\" unparsable, "), msg, | ||
786 | document_date); | ||
787 | strcpy(msg, tmp); | ||
788 | 766 | ||
789 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 767 | xasprintf(&sc_document_dates.output, _("Document date \"%100s\" unparsable"), |
768 | document_date); | ||
769 | sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_CRITICAL); | ||
790 | } else if (doc_data > srv_data + 30) { | 770 | } else if (doc_data > srv_data + 30) { |
791 | char tmp[DEFAULT_BUFFER_SIZE]; | ||
792 | 771 | ||
793 | snprintf(tmp, DEFAULT_BUFFER_SIZE, _("%sDocument is %d seconds in the future, "), msg, | 772 | xasprintf(&sc_document_dates.output, _("Document is %d seconds in the future"), |
794 | (int)doc_data - (int)srv_data); | 773 | (int)doc_data - (int)srv_data); |
795 | strcpy(msg, tmp); | ||
796 | 774 | ||
797 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 775 | sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_CRITICAL); |
798 | } else if (doc_data < srv_data - maximum_age) { | 776 | } else if (doc_data < srv_data - maximum_age) { |
799 | time_t last_modified = (srv_data - doc_data); | 777 | time_t last_modified = (srv_data - doc_data); |
800 | if (last_modified > (60 * 60 * 24 * 2)) { | 778 | if (last_modified > (60 * 60 * 24 * 2)) { // two days hardcoded? |
801 | char tmp[DEFAULT_BUFFER_SIZE]; | 779 | xasprintf(&sc_document_dates.output, _("Last modified %.1f days ago"), |
802 | 780 | ((float)last_modified) / (60 * 60 * 24)); | |
803 | snprintf(tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %.1f days ago, "), msg, | 781 | sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_CRITICAL); |
804 | ((float)last_modified) / (60 * 60 * 24)); | ||
805 | strcpy(msg, tmp); | ||
806 | |||
807 | date_result = max_state_alt(STATE_CRITICAL, date_result); | ||
808 | } else { | 782 | } else { |
809 | char tmp[DEFAULT_BUFFER_SIZE]; | 783 | xasprintf(&sc_document_dates.output, _("Last modified %ld:%02ld:%02ld ago"), |
810 | 784 | last_modified / (60 * 60), (last_modified / 60) % 60, last_modified % 60); | |
811 | snprintf(tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %ld:%02ld:%02ld ago, "), msg, | 785 | sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_CRITICAL); |
812 | last_modified / (60 * 60), (last_modified / 60) % 60, last_modified % 60); | ||
813 | strcpy(msg, tmp); | ||
814 | |||
815 | date_result = max_state_alt(STATE_CRITICAL, date_result); | ||
816 | } | 786 | } |
787 | } else { | ||
788 | // TODO is this the OK case? | ||
789 | time_t last_modified = (srv_data - doc_data); | ||
790 | xasprintf(&sc_document_dates.output, _("Last modified %ld:%02ld:%02ld ago"), | ||
791 | last_modified / (60 * 60), (last_modified / 60) % 60, last_modified % 60); | ||
792 | sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_OK); | ||
817 | } | 793 | } |
818 | } | 794 | } |
819 | 795 | ||
@@ -824,7 +800,7 @@ mp_state_enum check_document_dates(const curlhelp_write_curlbuf *header_buf, | |||
824 | free(document_date); | 800 | free(document_date); |
825 | } | 801 | } |
826 | 802 | ||
827 | return date_result; | 803 | return sc_document_dates; |
828 | } | 804 | } |
829 | 805 | ||
830 | void curlhelp_free_statusline(curlhelp_statusline *status_line) { free(status_line->first_line); } | 806 | void curlhelp_free_statusline(curlhelp_statusline *status_line) { free(status_line->first_line); } |
@@ -1172,46 +1148,117 @@ char *string_statuscode(int major, int minor) { | |||
1172 | return buf; | 1148 | return buf; |
1173 | } | 1149 | } |
1174 | 1150 | ||
1175 | char *perfd_time(double elapsed_time, thresholds *thlds, long socket_timeout) { | 1151 | /* check whether a file exists */ |
1176 | return fperfdata("time", elapsed_time, "s", (thlds->warning != NULL), | 1152 | void test_file(char *path) { |
1177 | thlds->warning ? thlds->warning->end : 0, (thlds->critical != NULL), | 1153 | if (access(path, R_OK) == 0) { |
1178 | thlds->critical ? thlds->critical->end : 0, true, 0, true, socket_timeout); | 1154 | return; |
1155 | } | ||
1156 | usage2(_("file does not exist or is not readable"), path); | ||
1179 | } | 1157 | } |
1180 | 1158 | ||
1181 | char *perfd_time_connect(double elapsed_time_connect, long socket_timeout) { | 1159 | mp_subcheck np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, |
1182 | return fperfdata("time_connect", elapsed_time_connect, "s", false, 0, false, 0, false, 0, true, | 1160 | int days_till_exp_crit); |
1183 | socket_timeout); | ||
1184 | } | ||
1185 | 1161 | ||
1186 | char *perfd_time_ssl(double elapsed_time_ssl, long socket_timeout) { | 1162 | mp_subcheck check_curl_certificate_checks(CURL *curl, X509 *cert, int warn_days_till_exp, |
1187 | return fperfdata("time_ssl", elapsed_time_ssl, "s", false, 0, false, 0, false, 0, true, | 1163 | int crit_days_till_exp) { |
1188 | socket_timeout); | 1164 | mp_subcheck sc_cert_result = mp_subcheck_init(); |
1189 | } | 1165 | sc_cert_result = mp_set_subcheck_default_state(sc_cert_result, STATE_OK); |
1190 | 1166 | ||
1191 | char *perfd_time_headers(double elapsed_time_headers, long socket_timeout) { | 1167 | #ifdef LIBCURL_FEATURE_SSL |
1192 | return fperfdata("time_headers", elapsed_time_headers, "s", false, 0, false, 0, false, 0, true, | 1168 | if (is_openssl_callback) { |
1193 | socket_timeout); | 1169 | # ifdef USE_OPENSSL |
1194 | } | 1170 | /* check certificate with OpenSSL functions, curl has been built against OpenSSL |
1171 | * and we actually have OpenSSL in the monitoring tools | ||
1172 | */ | ||
1173 | return np_net_ssl_check_certificate(cert, warn_days_till_exp, crit_days_till_exp); | ||
1174 | # else /* USE_OPENSSL */ | ||
1175 | xasprintf(&result.output, "HTTP CRITICAL - Cannot retrieve certificates - OpenSSL " | ||
1176 | "callback used and not linked against OpenSSL\n"); | ||
1177 | mp_set_subcheck_state(result, STATE_CRITICAL); | ||
1178 | # endif /* USE_OPENSSL */ | ||
1179 | } else { | ||
1180 | struct curl_slist *slist; | ||
1181 | |||
1182 | cert_ptr_union cert_ptr = {0}; | ||
1183 | cert_ptr.to_info = NULL; | ||
1184 | CURLcode res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &cert_ptr.to_info); | ||
1185 | if (!res && cert_ptr.to_info) { | ||
1186 | # ifdef USE_OPENSSL | ||
1187 | /* We have no OpenSSL in libcurl, but we can use OpenSSL for X509 cert | ||
1188 | * parsing We only check the first certificate and assume it's the one of | ||
1189 | * the server | ||
1190 | */ | ||
1191 | char *raw_cert = NULL; | ||
1192 | bool got_first_cert = false; | ||
1193 | for (int i = 0; i < cert_ptr.to_certinfo->num_of_certs; i++) { | ||
1194 | if (got_first_cert) { | ||
1195 | break; | ||
1196 | } | ||
1197 | |||
1198 | for (slist = cert_ptr.to_certinfo->certinfo[i]; slist; slist = slist->next) { | ||
1199 | if (verbose >= 2) { | ||
1200 | printf("%d ** %s\n", i, slist->data); | ||
1201 | } | ||
1202 | if (strncmp(slist->data, "Cert:", 5) == 0) { | ||
1203 | raw_cert = &slist->data[5]; | ||
1204 | got_first_cert = true; | ||
1205 | break; | ||
1206 | } | ||
1207 | } | ||
1208 | } | ||
1195 | 1209 | ||
1196 | char *perfd_time_firstbyte(double elapsed_time_firstbyte, long socket_timeout) { | 1210 | if (!raw_cert) { |
1197 | return fperfdata("time_firstbyte", elapsed_time_firstbyte, "s", false, 0, false, 0, false, 0, | ||
1198 | true, socket_timeout); | ||
1199 | } | ||
1200 | 1211 | ||
1201 | char *perfd_time_transfer(double elapsed_time_transfer, long socket_timeout) { | 1212 | xasprintf(&sc_cert_result.output, |
1202 | return fperfdata("time_transfer", elapsed_time_transfer, "s", false, 0, false, 0, false, 0, | 1213 | _("Cannot retrieve certificates from CERTINFO information - " |
1203 | true, socket_timeout); | 1214 | "certificate data was empty")); |
1204 | } | 1215 | sc_cert_result = mp_set_subcheck_state(sc_cert_result, STATE_CRITICAL); |
1216 | return sc_cert_result; | ||
1217 | } | ||
1218 | |||
1219 | BIO *cert_BIO = BIO_new(BIO_s_mem()); | ||
1220 | BIO_write(cert_BIO, raw_cert, (int)strlen(raw_cert)); | ||
1221 | |||
1222 | cert = PEM_read_bio_X509(cert_BIO, NULL, NULL, NULL); | ||
1223 | if (!cert) { | ||
1224 | xasprintf(&sc_cert_result.output, | ||
1225 | _("Cannot read certificate from CERTINFO information - BIO error")); | ||
1226 | sc_cert_result = mp_set_subcheck_state(sc_cert_result, STATE_CRITICAL); | ||
1227 | return sc_cert_result; | ||
1228 | } | ||
1205 | 1229 | ||
1206 | char *perfd_size(size_t page_len, int min_page_len) { | 1230 | BIO_free(cert_BIO); |
1207 | return perfdata("size", page_len, "B", (min_page_len > 0), min_page_len, (min_page_len > 0), 0, | 1231 | return np_net_ssl_check_certificate(cert, warn_days_till_exp, crit_days_till_exp); |
1208 | true, 0, false, 0); | 1232 | # else /* USE_OPENSSL */ |
1233 | /* We assume we don't have OpenSSL and np_net_ssl_check_certificate at our | ||
1234 | * disposal, so we use the libcurl CURLINFO data | ||
1235 | */ | ||
1236 | return net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, | ||
1237 | days_till_exp_crit); | ||
1238 | # endif /* USE_OPENSSL */ | ||
1239 | } else { | ||
1240 | xasprintf(&sc_cert_result.output, | ||
1241 | _("Cannot retrieve certificates - cURL returned %d - %s"), res, | ||
1242 | curl_easy_strerror(res)); | ||
1243 | mp_set_subcheck_state(sc_cert_result, STATE_CRITICAL); | ||
1244 | } | ||
1245 | } | ||
1246 | #endif /* LIBCURL_FEATURE_SSL */ | ||
1247 | |||
1248 | return sc_cert_result; | ||
1209 | } | 1249 | } |
1210 | 1250 | ||
1211 | /* check whether a file exists */ | 1251 | char *fmt_url(check_curl_working_state workingState) { |
1212 | void test_file(char *path) { | 1252 | char *url = calloc(DEFAULT_BUFFER_SIZE, sizeof(char)); |
1213 | if (access(path, R_OK) == 0) { | 1253 | if (url == NULL) { |
1214 | return; | 1254 | die(STATE_UNKNOWN, "memory allocation failed"); |
1215 | } | 1255 | } |
1216 | usage2(_("file does not exist or is not readable"), path); | 1256 | |
1257 | snprintf(url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s", workingState.use_ssl ? "https" : "http", | ||
1258 | (workingState.use_ssl & (workingState.host_name != NULL)) | ||
1259 | ? workingState.host_name | ||
1260 | : workingState.server_address, | ||
1261 | workingState.serverPort, workingState.server_url); | ||
1262 | |||
1263 | return url; | ||
1217 | } | 1264 | } |
diff --git a/plugins/check_curl.d/check_curl_helpers.h b/plugins/check_curl.d/check_curl_helpers.h index 0f43ab90..87e45a9d 100644 --- a/plugins/check_curl.d/check_curl_helpers.h +++ b/plugins/check_curl.d/check_curl_helpers.h | |||
@@ -1,7 +1,11 @@ | |||
1 | #include "./config.h" | 1 | #include "./config.h" |
2 | #include <curl/curl.h> | 2 | #include <curl/curl.h> |
3 | #include "../picohttpparser/picohttpparser.h" | 3 | #include "../picohttpparser/picohttpparser.h" |
4 | // #include "curl/easy.h" | 4 | #include "output.h" |
5 | |||
6 | #if defined(HAVE_SSL) && defined(USE_OPENSSL) | ||
7 | # include <openssl/opensslv.h> | ||
8 | #endif | ||
5 | 9 | ||
6 | /* for buffers for header and body */ | 10 | /* for buffers for header and body */ |
7 | typedef struct { | 11 | typedef struct { |
@@ -99,8 +103,8 @@ int curlhelp_parse_statusline(const char * /*buf*/, curlhelp_statusline * /*stat | |||
99 | void curlhelp_free_statusline(curlhelp_statusline * /*status_line*/); | 103 | void curlhelp_free_statusline(curlhelp_statusline * /*status_line*/); |
100 | 104 | ||
101 | char *get_header_value(const struct phr_header *headers, size_t nof_headers, const char *header); | 105 | char *get_header_value(const struct phr_header *headers, size_t nof_headers, const char *header); |
102 | mp_state_enum check_document_dates(const curlhelp_write_curlbuf * /*header_buf*/, | 106 | mp_subcheck check_document_dates(const curlhelp_write_curlbuf * /*header_buf*/, |
103 | const char msg[static DEFAULT_BUFFER_SIZE], int /*maximum_age*/); | 107 | int /*maximum_age*/); |
104 | size_t get_content_length(const curlhelp_write_curlbuf *header_buf, | 108 | size_t get_content_length(const curlhelp_write_curlbuf *header_buf, |
105 | const curlhelp_write_curlbuf *body_buf); | 109 | const curlhelp_write_curlbuf *body_buf); |
106 | int lookup_host(const char *host, char *buf, size_t buflen, sa_family_t addr_family); | 110 | int lookup_host(const char *host, char *buf, size_t buflen, sa_family_t addr_family); |
@@ -114,12 +118,7 @@ void cleanup(check_curl_global_state global_state); | |||
114 | bool expected_statuscode(const char *reply, const char *statuscodes); | 118 | bool expected_statuscode(const char *reply, const char *statuscodes); |
115 | char *string_statuscode(int major, int minor); | 119 | char *string_statuscode(int major, int minor); |
116 | 120 | ||
117 | char *perfd_time(double elapsed_time, thresholds * /*thlds*/, long /*socket_timeout*/); | ||
118 | char *perfd_time_connect(double elapsed_time_connect, long /*socket_timeout*/); | ||
119 | char *perfd_time_ssl(double elapsed_time_ssl, long /*socket_timeout*/); | ||
120 | char *perfd_time_firstbyte(double elapsed_time_firstbyte, long /*socket_timeout*/); | ||
121 | char *perfd_time_headers(double elapsed_time_headers, long /*socket_timeout*/); | ||
122 | char *perfd_time_transfer(double elapsed_time_transfer, long /*socket_timeout*/); | ||
123 | char *perfd_size(size_t page_len, int /*min_page_len*/); | ||
124 | |||
125 | void test_file(char *path); | 121 | void test_file(char *path); |
122 | mp_subcheck check_curl_certificate_checks(CURL *curl, X509 *cert, int warn_days_till_exp, | ||
123 | int crit_days_till_exp); | ||
124 | char *fmt_url(check_curl_working_state workingState); | ||
diff --git a/plugins/check_curl.d/config.h b/plugins/check_curl.d/config.h index a4b1eecf..32399b8a 100644 --- a/plugins/check_curl.d/config.h +++ b/plugins/check_curl.d/config.h | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <sys/socket.h> | 9 | #include <sys/socket.h> |
10 | #include "curl/curl.h" | 10 | #include "curl/curl.h" |
11 | #include "perfdata.h" | ||
11 | #include "regex.h" | 12 | #include "regex.h" |
12 | 13 | ||
13 | enum { | 14 | enum { |
@@ -93,9 +94,9 @@ typedef struct { | |||
93 | bool continue_after_check_cert; | 94 | bool continue_after_check_cert; |
94 | int days_till_exp_warn; | 95 | int days_till_exp_warn; |
95 | int days_till_exp_crit; | 96 | int days_till_exp_crit; |
96 | thresholds *thlds; | 97 | mp_thresholds thlds; |
97 | size_t min_page_len; | 98 | mp_range page_length_limits; |
98 | size_t max_page_len; | 99 | bool page_length_limits_is_set; |
99 | struct { | 100 | struct { |
100 | char string[MAX_INPUT_BUFFER]; | 101 | char string[MAX_INPUT_BUFFER]; |
101 | bool is_present; | 102 | bool is_present; |