summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-04-19 14:42:37 (GMT)
committerSven Nierlein <sven@nierlein.de>2018-10-22 14:30:31 (GMT)
commit88f566adf5d8d852298294474a4dfabe4be6d927 (patch)
treeb509b642e209e86d2321b723dba47f8d062a92c4 /plugins
parent55e8d89b0a24dc8a1a3d6ea031a2189b1cf3f497 (diff)
downloadmonitoring-plugins-88f566adf5d8d852298294474a4dfabe4be6d927.tar.gz
fixed some libcurl checks and minimal versions
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_curl.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 5ed47e2..9b14486 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -312,11 +312,7 @@ check_http (void)
312 if (!strcmp(http_method, "POST")) 312 if (!strcmp(http_method, "POST"))
313 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_POST, 1), "CURLOPT_POST"); 313 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_POST, 1), "CURLOPT_POST");
314 else if (!strcmp(http_method, "PUT")) 314 else if (!strcmp(http_method, "PUT"))
315#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 12, 1)
316 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_UPLOAD, 1), "CURLOPT_UPLOAD"); 315 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_UPLOAD, 1), "CURLOPT_UPLOAD");
317#else
318 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PUT, 1), "CURLOPT_PUT");
319#endif
320 else 316 else
321 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CUSTOMREQUEST, http_method), "CURLOPT_CUSTOMREQUEST"); 317 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CUSTOMREQUEST, http_method), "CURLOPT_CUSTOMREQUEST");
322 } 318 }
@@ -370,22 +366,22 @@ check_http (void)
370#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) 366#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1)
371 /* inform curl to report back certificates (this works for OpenSSL, NSS at least) */ 367 /* inform curl to report back certificates (this works for OpenSSL, NSS at least) */
372 curl_easy_setopt (curl, CURLOPT_CERTINFO, 1L); 368 curl_easy_setopt (curl, CURLOPT_CERTINFO, 1L);
373#ifdef USE_OPENSSL 369#ifdef LIBCURL_USES_OPENSSL
374 /* set callback to extract certificate with OpenSSL context function (works with 370 /* set callback to extract certificate with OpenSSL context function (works with
375 * OpenSSL only!) 371 * OpenSSL only!)
376 */ 372 */
377 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION"); 373 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
378#endif /* USE_OPENSSL */ 374#endif /* USE_OPENSSL */
379#else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */ 375#else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */
380#ifdef USE_OPENSSL 376#ifdef LIBCURL_USES_OPENSSL
381 /* Too old curl library, hope we have OpenSSL */ 377 /* Too old curl library, hope we have OpenSSL */
382 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION"); 378 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
383#else 379#else
384 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (no CURLOPT_SSL_CTX_FUNCTION, no OpenSSL library)\n"); 380 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (no CURLOPT_SSL_CTX_FUNCTION, no OpenSSL library)\n");
385#endif /* USE_OPENSSL */ 381#endif /* LIBCURL_USES_OPENSSL */
386#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */ 382#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */
387 383
388#endif /* HAVE_SSL */ 384#endif /* LIBCURL_FEATURE_SSL */
389 385
390 /* set default or user-given user agent identification */ 386 /* set default or user-given user agent identification */
391 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERAGENT, user_agent), "CURLOPT_USERAGENT"); 387 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERAGENT, user_agent), "CURLOPT_USERAGENT");
@@ -429,7 +425,7 @@ check_http (void)
429 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_WHATEVER)"); 425 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_WHATEVER)");
430 else if (address_family == AF_INET) 426 else if (address_family == AF_INET)
431 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_V4)"); 427 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_V4)");
432#ifdef USE_IPV6 428#if defined (USE_IPV6) && defined (LIBCURL_FEATURE_IPV6)
433 else if (address_family == AF_INET6) 429 else if (address_family == AF_INET6)
434 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_V6)"); 430 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_V6)");
435#endif 431#endif
@@ -500,9 +496,9 @@ check_http (void)
500 * and we actually have OpenSSL in the monitoring tools 496 * and we actually have OpenSSL in the monitoring tools
501 */ 497 */
502#ifdef HAVE_SSL 498#ifdef HAVE_SSL
503#ifdef USE_OPENSSL 499#ifdef LIBCURL_USES_OPENSSL
504 result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); 500 result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
505#endif /* USE_OPENSSL */ 501#endif /* LIBCURL_USES_OPENSSL */
506#endif /* HAVE_SSL */ 502#endif /* HAVE_SSL */
507 return result; 503 return result;
508 } 504 }
@@ -1061,7 +1057,7 @@ process_arguments (int argc, char **argv)
1061 address_family = AF_INET; 1057 address_family = AF_INET;
1062 break; 1058 break;
1063 case '6': 1059 case '6':
1064#ifdef USE_IPV6 1060#if defined (USE_IPV6) && defined (LIBCURL_FEATURE_IPV6)
1065 address_family = AF_INET6; 1061 address_family = AF_INET6;
1066#else 1062#else
1067 usage4 (_("IPv6 support not available")); 1063 usage4 (_("IPv6 support not available"));