diff options
author | Sven Nierlein <sven@nierlein.de> | 2018-10-22 17:53:31 +0200 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2018-10-22 17:53:31 +0200 |
commit | 0958ce4b829652e5b5c74f0496507ec7ec48014b (patch) | |
tree | 630a20c2d545c3afb7a1981caac02cf777d8f336 | |
parent | 61571ce854d777cda9d00c9b7424caf400573240 (diff) | |
download | monitoring-plugins-0958ce4b829652e5b5c74f0496507ec7ec48014b.tar.gz |
check_curl: unify performance data
and align them with check_http
-rw-r--r-- | plugins/check_curl.c | 84 |
1 files changed, 61 insertions, 23 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 26be33c1..63c07e3e 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -207,6 +207,13 @@ int process_arguments (int, char**); | |||
207 | void handle_curl_option_return_code (CURLcode res, const char* option); | 207 | void handle_curl_option_return_code (CURLcode res, const char* option); |
208 | int check_http (void); | 208 | int check_http (void); |
209 | void redir (curlhelp_write_curlbuf*); | 209 | void redir (curlhelp_write_curlbuf*); |
210 | char *perfd_time (double microsec); | ||
211 | char *perfd_time_connect (double microsec); | ||
212 | char *perfd_time_ssl (double microsec); | ||
213 | char *perfd_time_firstbyte (double microsec); | ||
214 | char *perfd_time_headers (double microsec); | ||
215 | char *perfd_time_transfer (double microsec); | ||
216 | char *perfd_size (int page_len); | ||
210 | void print_help (void); | 217 | void print_help (void); |
211 | void print_usage (void); | 218 | void print_usage (void); |
212 | void print_curl_version (void); | 219 | void print_curl_version (void); |
@@ -222,7 +229,6 @@ int net_noopenssl_check_certificate (cert_ptr_union*, int, int); | |||
222 | 229 | ||
223 | int curlhelp_parse_statusline (const char*, curlhelp_statusline *); | 230 | int curlhelp_parse_statusline (const char*, curlhelp_statusline *); |
224 | void curlhelp_free_statusline (curlhelp_statusline *); | 231 | void curlhelp_free_statusline (curlhelp_statusline *); |
225 | char *perfd_time_ssl (double microsec); | ||
226 | char *get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header); | 232 | char *get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header); |
227 | int check_document_dates (const curlhelp_write_curlbuf *, char (*msg)[DEFAULT_BUFFER_SIZE]); | 233 | int check_document_dates (const curlhelp_write_curlbuf *, char (*msg)[DEFAULT_BUFFER_SIZE]); |
228 | int get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf); | 234 | int get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf); |
@@ -710,23 +716,20 @@ GOT_FIRST_CERT: | |||
710 | handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME, &time_appconnect), "CURLINFO_APPCONNECT_TIME"); | 716 | handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME, &time_appconnect), "CURLINFO_APPCONNECT_TIME"); |
711 | handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_headers), "CURLINFO_PRETRANSFER_TIME"); | 717 | handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_headers), "CURLINFO_PRETRANSFER_TIME"); |
712 | handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &time_firstbyte), "CURLINFO_STARTTRANSFER_TIME"); | 718 | handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &time_firstbyte), "CURLINFO_STARTTRANSFER_TIME"); |
713 | snprintf(perfstring, DEFAULT_BUFFER_SIZE, "time=%.6gs;%.6g;%.6g;; size=%dB;;; time_connect=%.6gs;;;; %s time_headers=%.6gs;;;; time_firstbyte=%.6gs;;;; time_transfer=%.6gs;;;;", | 719 | snprintf(perfstring, DEFAULT_BUFFER_SIZE, "%s %s %s %s %s %s %s", |
714 | total_time, | 720 | perfd_time(total_time), |
715 | warning_thresholds != NULL ? (double)thlds->warning->end : 0.0, | 721 | perfd_size(page_len), |
716 | critical_thresholds != NULL ? (double)thlds->critical->end : 0.0, | 722 | perfd_time_connect(time_connect), |
717 | page_len, | 723 | use_ssl == TRUE ? perfd_time_ssl (time_appconnect-time_connect) : "", |
718 | time_connect, | 724 | perfd_time_headers(time_headers - time_appconnect), |
719 | use_ssl == TRUE ? perfd_time_ssl(time_appconnect-time_connect) : "", | 725 | perfd_time_firstbyte(time_firstbyte - time_headers), |
720 | (time_headers - time_appconnect), | 726 | perfd_time_transfer(total_time-time_firstbyte) |
721 | (time_firstbyte - time_headers), | 727 | ); |
722 | (total_time-time_firstbyte) | ||
723 | ); | ||
724 | } else { | 728 | } else { |
725 | snprintf(perfstring, DEFAULT_BUFFER_SIZE, "time=%.6gs;%.6g;%.6g;; size=%dB;;;", | 729 | snprintf(perfstring, DEFAULT_BUFFER_SIZE, "%s %s", |
726 | total_time, | 730 | perfd_time(total_time), |
727 | warning_thresholds != NULL ? (double)thlds->warning->end : 0.0, | 731 | perfd_size(page_len) |
728 | critical_thresholds != NULL ? (double)thlds->critical->end : 0.0, | 732 | ); |
729 | page_len); | ||
730 | } | 733 | } |
731 | 734 | ||
732 | /* return a CRITICAL status if we couldn't read any data */ | 735 | /* return a CRITICAL status if we couldn't read any data */ |
@@ -1547,6 +1550,47 @@ process_arguments (int argc, char **argv) | |||
1547 | return TRUE; | 1550 | return TRUE; |
1548 | } | 1551 | } |
1549 | 1552 | ||
1553 | char *perfd_time (double elapsed_time) | ||
1554 | { | ||
1555 | return fperfdata ("time", elapsed_time, "s", | ||
1556 | thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0, | ||
1557 | thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0, | ||
1558 | TRUE, 0, TRUE, socket_timeout); | ||
1559 | } | ||
1560 | |||
1561 | char *perfd_time_connect (double elapsed_time_connect) | ||
1562 | { | ||
1563 | return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | ||
1564 | } | ||
1565 | |||
1566 | char *perfd_time_ssl (double elapsed_time_ssl) | ||
1567 | { | ||
1568 | return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | ||
1569 | } | ||
1570 | |||
1571 | char *perfd_time_headers (double elapsed_time_headers) | ||
1572 | { | ||
1573 | return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | ||
1574 | } | ||
1575 | |||
1576 | char *perfd_time_firstbyte (double elapsed_time_firstbyte) | ||
1577 | { | ||
1578 | return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | ||
1579 | } | ||
1580 | |||
1581 | char *perfd_time_transfer (double elapsed_time_transfer) | ||
1582 | { | ||
1583 | return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | ||
1584 | } | ||
1585 | |||
1586 | char *perfd_size (int page_len) | ||
1587 | { | ||
1588 | return perfdata ("size", page_len, "B", | ||
1589 | (min_page_len>0?TRUE:FALSE), min_page_len, | ||
1590 | (min_page_len>0?TRUE:FALSE), 0, | ||
1591 | TRUE, 0, FALSE, 0); | ||
1592 | } | ||
1593 | |||
1550 | void | 1594 | void |
1551 | print_help (void) | 1595 | print_help (void) |
1552 | { | 1596 | { |
@@ -1946,12 +1990,6 @@ remove_newlines (char *s) | |||
1946 | } | 1990 | } |
1947 | 1991 | ||
1948 | char * | 1992 | char * |
1949 | perfd_time_ssl (double elapsed_time_ssl) | ||
1950 | { | ||
1951 | return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); | ||
1952 | } | ||
1953 | |||
1954 | char * | ||
1955 | get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header) | 1993 | get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header) |
1956 | { | 1994 | { |
1957 | int i; | 1995 | int i; |