summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_curl.c84
1 files changed, 61 insertions, 23 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 26be33c..63c07e3 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -207,6 +207,13 @@ int process_arguments (int, char**);
207void handle_curl_option_return_code (CURLcode res, const char* option); 207void handle_curl_option_return_code (CURLcode res, const char* option);
208int check_http (void); 208int check_http (void);
209void redir (curlhelp_write_curlbuf*); 209void redir (curlhelp_write_curlbuf*);
210char *perfd_time (double microsec);
211char *perfd_time_connect (double microsec);
212char *perfd_time_ssl (double microsec);
213char *perfd_time_firstbyte (double microsec);
214char *perfd_time_headers (double microsec);
215char *perfd_time_transfer (double microsec);
216char *perfd_size (int page_len);
210void print_help (void); 217void print_help (void);
211void print_usage (void); 218void print_usage (void);
212void print_curl_version (void); 219void print_curl_version (void);
@@ -222,7 +229,6 @@ int net_noopenssl_check_certificate (cert_ptr_union*, int, int);
222 229
223int curlhelp_parse_statusline (const char*, curlhelp_statusline *); 230int curlhelp_parse_statusline (const char*, curlhelp_statusline *);
224void curlhelp_free_statusline (curlhelp_statusline *); 231void curlhelp_free_statusline (curlhelp_statusline *);
225char *perfd_time_ssl (double microsec);
226char *get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header); 232char *get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header);
227int check_document_dates (const curlhelp_write_curlbuf *, char (*msg)[DEFAULT_BUFFER_SIZE]); 233int check_document_dates (const curlhelp_write_curlbuf *, char (*msg)[DEFAULT_BUFFER_SIZE]);
228int get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf); 234int 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
1553char *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
1561char *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
1566char *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
1571char *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
1576char *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
1581char *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
1586char *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
1550void 1594void
1551print_help (void) 1595print_help (void)
1552{ 1596{
@@ -1946,12 +1990,6 @@ remove_newlines (char *s)
1946} 1990}
1947 1991
1948char * 1992char *
1949perfd_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
1954char *
1955get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header) 1993get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header)
1956{ 1994{
1957 int i; 1995 int i;