diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_curl.c | 65 | ||||
-rw-r--r-- | plugins/check_disk.c | 83 | ||||
-rw-r--r-- | plugins/check_mysql.c | 8 | ||||
-rw-r--r-- | plugins/check_snmp.c | 168 |
4 files changed, 163 insertions, 161 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 01e2770..d3bddac 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -214,6 +214,7 @@ char *client_privkey = NULL; | |||
214 | char *ca_cert = NULL; | 214 | char *ca_cert = NULL; |
215 | bool verify_peer_and_host = false; | 215 | bool verify_peer_and_host = false; |
216 | bool is_openssl_callback = false; | 216 | bool is_openssl_callback = false; |
217 | bool add_sslctx_verify_fun = false; | ||
217 | #if defined(HAVE_SSL) && defined(USE_OPENSSL) | 218 | #if defined(HAVE_SSL) && defined(USE_OPENSSL) |
218 | X509 *cert = NULL; | 219 | X509 *cert = NULL; |
219 | #endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */ | 220 | #endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */ |
@@ -299,7 +300,7 @@ main (int argc, char **argv) | |||
299 | 300 | ||
300 | int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) | 301 | int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) |
301 | { | 302 | { |
302 | (void) preverify_ok; | 303 | (void) preverify_ok; |
303 | /* TODO: we get all certificates of the chain, so which ones | 304 | /* TODO: we get all certificates of the chain, so which ones |
304 | * should we test? | 305 | * should we test? |
305 | * TODO: is the last certificate always the server certificate? | 306 | * TODO: is the last certificate always the server certificate? |
@@ -324,9 +325,18 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) | |||
324 | 325 | ||
325 | CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm) | 326 | CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm) |
326 | { | 327 | { |
327 | (void) curl; // ignore unused parameter | 328 | (void) curl; // ignore unused parameter |
328 | (void) parm; // ignore unused parameter | 329 | (void) parm; // ignore unused parameter |
329 | SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback); | 330 | if(add_sslctx_verify_fun) { |
331 | SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback); | ||
332 | } | ||
333 | |||
334 | // workaround for issue: | ||
335 | // OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0 | ||
336 | // see discussion https://github.com/openssl/openssl/discussions/22690 | ||
337 | #ifdef SSL_OP_IGNORE_UNEXPECTED_EOF | ||
338 | SSL_CTX_set_options(sslctx, SSL_OP_IGNORE_UNEXPECTED_EOF); | ||
339 | #endif | ||
330 | 340 | ||
331 | return CURLE_OK; | 341 | return CURLE_OK; |
332 | } | 342 | } |
@@ -468,6 +478,7 @@ int | |||
468 | check_http (void) | 478 | check_http (void) |
469 | { | 479 | { |
470 | int result = STATE_OK; | 480 | int result = STATE_OK; |
481 | int result_ssl = STATE_OK; | ||
471 | int page_len = 0; | 482 | int page_len = 0; |
472 | int i; | 483 | int i; |
473 | char *force_host_header = NULL; | 484 | char *force_host_header = NULL; |
@@ -677,9 +688,8 @@ check_http (void) | |||
677 | * OpenSSL-style libraries only!) */ | 688 | * OpenSSL-style libraries only!) */ |
678 | #ifdef USE_OPENSSL | 689 | #ifdef USE_OPENSSL |
679 | /* libcurl and monitoring plugins built with OpenSSL, good */ | 690 | /* libcurl and monitoring plugins built with OpenSSL, good */ |
680 | handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION"); | 691 | add_sslctx_verify_fun = true; |
681 | is_openssl_callback = true; | 692 | is_openssl_callback = true; |
682 | #else /* USE_OPENSSL */ | ||
683 | #endif /* USE_OPENSSL */ | 693 | #endif /* USE_OPENSSL */ |
684 | /* libcurl is built with OpenSSL, monitoring plugins, so falling | 694 | /* libcurl is built with OpenSSL, monitoring plugins, so falling |
685 | * back to manually extracting certificate information */ | 695 | * back to manually extracting certificate information */ |
@@ -712,12 +722,18 @@ check_http (void) | |||
712 | #else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */ | 722 | #else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */ |
713 | /* old libcurl, our only hope is OpenSSL, otherwise we are out of luck */ | 723 | /* old libcurl, our only hope is OpenSSL, otherwise we are out of luck */ |
714 | if (ssl_library == CURLHELP_SSL_LIBRARY_OPENSSL || ssl_library == CURLHELP_SSL_LIBRARY_LIBRESSL) | 724 | if (ssl_library == CURLHELP_SSL_LIBRARY_OPENSSL || ssl_library == CURLHELP_SSL_LIBRARY_LIBRESSL) |
715 | handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION"); | 725 | add_sslctx_verify_fun = true; |
716 | else | 726 | else |
717 | die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (no CURLOPT_SSL_CTX_FUNCTION, no OpenSSL library or libcurl too old and has no CURLOPT_CERTINFO)\n"); | 727 | die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (no CURLOPT_SSL_CTX_FUNCTION, no OpenSSL library or libcurl too old and has no CURLOPT_CERTINFO)\n"); |
718 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */ | 728 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */ |
719 | } | 729 | } |
720 | 730 | ||
731 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 10, 6) /* required for CURLOPT_SSL_CTX_FUNCTION */ | ||
732 | // ssl ctx function is not available with all ssl backends | ||
733 | if (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, NULL) != CURLE_UNKNOWN_OPTION) | ||
734 | handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION"); | ||
735 | #endif | ||
736 | |||
721 | #endif /* LIBCURL_FEATURE_SSL */ | 737 | #endif /* LIBCURL_FEATURE_SSL */ |
722 | 738 | ||
723 | /* set default or user-given user agent identification */ | 739 | /* set default or user-given user agent identification */ |
@@ -852,9 +868,9 @@ check_http (void) | |||
852 | /* check certificate with OpenSSL functions, curl has been built against OpenSSL | 868 | /* check certificate with OpenSSL functions, curl has been built against OpenSSL |
853 | * and we actually have OpenSSL in the monitoring tools | 869 | * and we actually have OpenSSL in the monitoring tools |
854 | */ | 870 | */ |
855 | result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); | 871 | result_ssl = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); |
856 | if (!continue_after_check_cert) { | 872 | if (!continue_after_check_cert) { |
857 | return result; | 873 | return result_ssl; |
858 | } | 874 | } |
859 | #else /* USE_OPENSSL */ | 875 | #else /* USE_OPENSSL */ |
860 | die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates - OpenSSL callback used and not linked against OpenSSL\n"); | 876 | die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates - OpenSSL callback used and not linked against OpenSSL\n"); |
@@ -898,17 +914,17 @@ GOT_FIRST_CERT: | |||
898 | die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); | 914 | die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); |
899 | } | 915 | } |
900 | BIO_free (cert_BIO); | 916 | BIO_free (cert_BIO); |
901 | result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); | 917 | result_ssl = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); |
902 | if (!continue_after_check_cert) { | 918 | if (!continue_after_check_cert) { |
903 | return result; | 919 | return result_ssl; |
904 | } | 920 | } |
905 | #else /* USE_OPENSSL */ | 921 | #else /* USE_OPENSSL */ |
906 | /* We assume we don't have OpenSSL and np_net_ssl_check_certificate at our disposal, | 922 | /* We assume we don't have OpenSSL and np_net_ssl_check_certificate at our disposal, |
907 | * so we use the libcurl CURLINFO data | 923 | * so we use the libcurl CURLINFO data |
908 | */ | 924 | */ |
909 | result = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit); | 925 | result_ssl = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit); |
910 | if (!continue_after_check_cert) { | 926 | if (!continue_after_check_cert) { |
911 | return result; | 927 | return result_ssl; |
912 | } | 928 | } |
913 | #endif /* USE_OPENSSL */ | 929 | #endif /* USE_OPENSSL */ |
914 | } else { | 930 | } else { |
@@ -1176,7 +1192,7 @@ GOT_FIRST_CERT: | |||
1176 | } | 1192 | } |
1177 | 1193 | ||
1178 | /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ | 1194 | /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ |
1179 | die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s", | 1195 | die (max_state_alt(result, result_ssl), "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s", |
1180 | state_text(result), string_statuscode (status_line.http_major, status_line.http_minor), | 1196 | state_text(result), string_statuscode (status_line.http_major, status_line.http_minor), |
1181 | status_line.http_code, status_line.msg, | 1197 | status_line.http_code, status_line.msg, |
1182 | strlen(msg) > 0 ? " - " : "", | 1198 | strlen(msg) > 0 ? " - " : "", |
@@ -1186,7 +1202,7 @@ GOT_FIRST_CERT: | |||
1186 | (show_body ? body_buf.buf : ""), | 1202 | (show_body ? body_buf.buf : ""), |
1187 | (show_body ? "\n" : "") ); | 1203 | (show_body ? "\n" : "") ); |
1188 | 1204 | ||
1189 | return result; | 1205 | return max_state_alt(result, result_ssl); |
1190 | } | 1206 | } |
1191 | 1207 | ||
1192 | int | 1208 | int |
@@ -1774,9 +1790,9 @@ process_arguments (int argc, char **argv) | |||
1774 | invert_regex = true; | 1790 | invert_regex = true; |
1775 | break; | 1791 | break; |
1776 | case STATE_REGEX: | 1792 | case STATE_REGEX: |
1777 | if (!strcmp (optarg, "critical")) | 1793 | if (!strcasecmp (optarg, "critical")) |
1778 | state_regex = STATE_CRITICAL; | 1794 | state_regex = STATE_CRITICAL; |
1779 | else if (!strcmp (optarg, "warning")) | 1795 | else if (!strcasecmp (optarg, "warning")) |
1780 | state_regex = STATE_WARNING; | 1796 | state_regex = STATE_WARNING; |
1781 | else usage2 (_("Invalid state-regex option"), optarg); | 1797 | else usage2 (_("Invalid state-regex option"), optarg); |
1782 | break; | 1798 | break; |
@@ -2007,8 +2023,11 @@ print_help (void) | |||
2007 | printf (" %s\n", _("Note: SNI is not supported in libcurl before 7.18.1")); | 2023 | printf (" %s\n", _("Note: SNI is not supported in libcurl before 7.18.1")); |
2008 | #endif | 2024 | #endif |
2009 | printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]"); | 2025 | printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]"); |
2010 | printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443")); | 2026 | printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443.")); |
2011 | printf (" %s\n", _("(when this option is used the URL is not checked by default. You can use")); | 2027 | printf (" %s\n", _("A STATE_WARNING is returned if the certificate has a validity less than the")); |
2028 | printf (" %s\n", _("first agument's value. If there is a second argument and the certificate's")); | ||
2029 | printf (" %s\n", _("validity is less than its value, a STATE_CRITICAL is returned.")); | ||
2030 | printf (" %s\n", _("(When this option is used the URL is not checked by default. You can use")); | ||
2012 | printf (" %s\n", _(" --continue-after-certificate to override this behavior)")); | 2031 | printf (" %s\n", _(" --continue-after-certificate to override this behavior)")); |
2013 | printf (" %s\n", "--continue-after-certificate"); | 2032 | printf (" %s\n", "--continue-after-certificate"); |
2014 | printf (" %s\n", _("Allows the HTTP check to continue after performing the certificate check.")); | 2033 | printf (" %s\n", _("Allows the HTTP check to continue after performing the certificate check.")); |
@@ -2057,8 +2076,8 @@ print_help (void) | |||
2057 | printf (" %s\n", "--invert-regex"); | 2076 | printf (" %s\n", "--invert-regex"); |
2058 | printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)")); | 2077 | printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)")); |
2059 | printf (" %s\n", _("can be changed with --state--regex)")); | 2078 | printf (" %s\n", _("can be changed with --state--regex)")); |
2060 | printf (" %s\n", "--regex-state=STATE"); | 2079 | printf (" %s\n", "--state-regex=STATE"); |
2061 | printf (" %s\n", _("Return STATE if regex is found, OK if not\n")); | 2080 | printf (" %s\n", _("Return STATE if regex is found, OK if not. STATE can be one of \"critical\",\"warning\"")); |
2062 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); | 2081 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); |
2063 | printf (" %s\n", _("Username:password on sites with basic authentication")); | 2082 | printf (" %s\n", _("Username:password on sites with basic authentication")); |
2064 | printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR"); | 2083 | printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR"); |
@@ -2091,7 +2110,7 @@ print_help (void) | |||
2091 | printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING).")); | 2110 | printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING).")); |
2092 | printf(" %s\n", "--haproxy-protocol"); | 2111 | printf(" %s\n", "--haproxy-protocol"); |
2093 | printf(" %s\n", _("Send HAProxy proxy protocol v1 header (CURLOPT_HAPROXYPROTOCOL).")); | 2112 | printf(" %s\n", _("Send HAProxy proxy protocol v1 header (CURLOPT_HAPROXYPROTOCOL).")); |
2094 | printf (" %s\n", "---cookie-jar=FILE"); | 2113 | printf (" %s\n", "--cookie-jar=FILE"); |
2095 | printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested.")); | 2114 | printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested.")); |
2096 | printf ("\n"); | 2115 | printf ("\n"); |
2097 | 2116 | ||
@@ -2186,8 +2205,6 @@ print_usage (void) | |||
2186 | printf ("%s\n", _("In the first form, make an HTTP request.")); | 2205 | printf ("%s\n", _("In the first form, make an HTTP request.")); |
2187 | printf ("%s\n\n", _("In the second form, connect to the server and check the TLS certificate.")); | 2206 | printf ("%s\n\n", _("In the second form, connect to the server and check the TLS certificate.")); |
2188 | #endif | 2207 | #endif |
2189 | printf ("%s\n", _("WARNING: check_curl is experimental. Please use")); | ||
2190 | printf ("%s\n\n", _("check_http if you need a stable version.")); | ||
2191 | } | 2208 | } |
2192 | 2209 | ||
2193 | void | 2210 | void |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 24de2d4..b3dd301 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -119,44 +119,41 @@ enum | |||
119 | #pragma alloca | 119 | #pragma alloca |
120 | #endif | 120 | #endif |
121 | 121 | ||
122 | int process_arguments (int, char **); | 122 | static int process_arguments (int, char **); |
123 | void print_path (const char *mypath); | 123 | static void set_all_thresholds (struct parameter_list *path); |
124 | void set_all_thresholds (struct parameter_list *path); | 124 | static void print_help (void); |
125 | int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, char *); | ||
126 | void print_help (void); | ||
127 | void print_usage (void); | 125 | void print_usage (void); |
128 | double calculate_percent(uintmax_t, uintmax_t); | 126 | static double calculate_percent(uintmax_t, uintmax_t); |
129 | bool stat_path (struct parameter_list *p); | 127 | static bool stat_path (struct parameter_list *p); |
130 | void get_stats (struct parameter_list *p, struct fs_usage *fsp); | 128 | static void get_stats (struct parameter_list *p, struct fs_usage *fsp); |
131 | void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); | 129 | static void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); |
132 | 130 | ||
133 | char *exclude_device; | 131 | static char *units; |
134 | char *units; | 132 | static uintmax_t mult = 1024 * 1024; |
135 | uintmax_t mult = 1024 * 1024; | 133 | static int verbose = 0; |
136 | int verbose = 0; | 134 | static bool erronly = false; |
137 | bool erronly = false; | 135 | static bool display_mntp = false; |
138 | bool display_mntp = false; | 136 | static bool exact_match = false; |
139 | bool exact_match = false; | 137 | static bool ignore_missing = false; |
140 | bool ignore_missing = false; | 138 | static bool freespace_ignore_reserved = false; |
141 | bool freespace_ignore_reserved = false; | 139 | static bool display_inodes_perfdata = false; |
142 | bool display_inodes_perfdata = false; | 140 | static char *warn_freespace_units = NULL; |
143 | char *warn_freespace_units = NULL; | 141 | static char *crit_freespace_units = NULL; |
144 | char *crit_freespace_units = NULL; | 142 | static char *warn_freespace_percent = NULL; |
145 | char *warn_freespace_percent = NULL; | 143 | static char *crit_freespace_percent = NULL; |
146 | char *crit_freespace_percent = NULL; | 144 | static char *warn_usedspace_units = NULL; |
147 | char *warn_usedspace_units = NULL; | 145 | static char *crit_usedspace_units = NULL; |
148 | char *crit_usedspace_units = NULL; | 146 | static char *warn_usedspace_percent = NULL; |
149 | char *warn_usedspace_percent = NULL; | 147 | static char *crit_usedspace_percent = NULL; |
150 | char *crit_usedspace_percent = NULL; | 148 | static char *warn_usedinodes_percent = NULL; |
151 | char *warn_usedinodes_percent = NULL; | 149 | static char *crit_usedinodes_percent = NULL; |
152 | char *crit_usedinodes_percent = NULL; | 150 | static char *warn_freeinodes_percent = NULL; |
153 | char *warn_freeinodes_percent = NULL; | 151 | static char *crit_freeinodes_percent = NULL; |
154 | char *crit_freeinodes_percent = NULL; | 152 | static bool path_selected = false; |
155 | bool path_selected = false; | 153 | static bool path_ignored = false; |
156 | bool path_ignored = false; | 154 | static char *group = NULL; |
157 | char *group = NULL; | 155 | static struct stat *stat_buf; |
158 | struct stat *stat_buf; | 156 | static struct name_list *seen = NULL; |
159 | struct name_list *seen = NULL; | ||
160 | 157 | ||
161 | 158 | ||
162 | int | 159 | int |
@@ -899,18 +896,6 @@ process_arguments (int argc, char **argv) | |||
899 | return true; | 896 | return true; |
900 | } | 897 | } |
901 | 898 | ||
902 | |||
903 | |||
904 | void | ||
905 | print_path (const char *mypath) | ||
906 | { | ||
907 | if (mypath == NULL) | ||
908 | printf ("\n"); | ||
909 | else | ||
910 | printf (_(" for %s\n"), mypath); | ||
911 | } | ||
912 | |||
913 | |||
914 | void | 899 | void |
915 | set_all_thresholds (struct parameter_list *path) | 900 | set_all_thresholds (struct parameter_list *path) |
916 | { | 901 | { |
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 6a7daf1..15ec04c 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
@@ -59,8 +59,8 @@ bool ssl = false; | |||
59 | char *opt_file = NULL; | 59 | char *opt_file = NULL; |
60 | char *opt_group = NULL; | 60 | char *opt_group = NULL; |
61 | unsigned int db_port = MYSQL_PORT; | 61 | unsigned int db_port = MYSQL_PORT; |
62 | int check_slave = 0, warn_sec = 0, crit_sec = 0; | 62 | bool check_slave = false; |
63 | int ignore_auth = 0; | 63 | bool ignore_auth = false; |
64 | int verbose = 0; | 64 | int verbose = 0; |
65 | 65 | ||
66 | static double warning_time = 0; | 66 | static double warning_time = 0; |
@@ -456,10 +456,10 @@ process_arguments (int argc, char **argv) | |||
456 | db_port = atoi (optarg); | 456 | db_port = atoi (optarg); |
457 | break; | 457 | break; |
458 | case 'S': | 458 | case 'S': |
459 | check_slave = 1; /* check-slave */ | 459 | check_slave = true; /* check-slave */ |
460 | break; | 460 | break; |
461 | case 'n': | 461 | case 'n': |
462 | ignore_auth = 1; /* ignore-auth */ | 462 | ignore_auth = true; /* ignore-auth */ |
463 | break; | 463 | break; |
464 | case 'w': | 464 | case 'w': |
465 | warning = optarg; | 465 | warning = optarg; |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 295aa9b..90a0402 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -55,8 +55,6 @@ const char *email = "devel@monitoring-plugins.org"; | |||
55 | #define CRIT_STRING 2 | 55 | #define CRIT_STRING 2 |
56 | #define CRIT_REGEX 4 | 56 | #define CRIT_REGEX 4 |
57 | #define WARN_PRESENT 8 | 57 | #define WARN_PRESENT 8 |
58 | #define WARN_STRING 16 | ||
59 | #define WARN_REGEX 32 | ||
60 | 58 | ||
61 | #define OID_COUNT_STEP 8 | 59 | #define OID_COUNT_STEP 8 |
62 | 60 | ||
@@ -86,82 +84,82 @@ const char *email = "devel@monitoring-plugins.org"; | |||
86 | 84 | ||
87 | 85 | ||
88 | 86 | ||
89 | int process_arguments (int, char **); | 87 | static int process_arguments (int, char **); |
90 | int validate_arguments (void); | 88 | static int validate_arguments (void); |
91 | char *thisarg (char *str); | 89 | static char *thisarg (char *str); |
92 | char *nextarg (char *str); | 90 | static char *nextarg (char *str); |
93 | void print_usage (void); | 91 | void print_usage (void); |
94 | void print_help (void); | 92 | static void print_help (void); |
95 | char *multiply (char *str); | 93 | static char *multiply (char *str); |
96 | 94 | ||
97 | #include "regex.h" | 95 | #include "regex.h" |
98 | char regex_expect[MAX_INPUT_BUFFER] = ""; | 96 | static char regex_expect[MAX_INPUT_BUFFER] = ""; |
99 | regex_t preg; | 97 | static regex_t preg; |
100 | regmatch_t pmatch[10]; | 98 | static regmatch_t pmatch[10]; |
101 | char errbuf[MAX_INPUT_BUFFER] = ""; | 99 | static char errbuf[MAX_INPUT_BUFFER] = ""; |
102 | char perfstr[MAX_INPUT_BUFFER] = "| "; | 100 | static char perfstr[MAX_INPUT_BUFFER] = "| "; |
103 | int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | 101 | static int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; |
104 | int eflags = 0; | 102 | static int eflags = 0; |
105 | int errcode, excode; | 103 | static int errcode, excode; |
106 | 104 | ||
107 | char *server_address = NULL; | 105 | static char *server_address = NULL; |
108 | char *community = NULL; | 106 | static char *community = NULL; |
109 | char **contextargs = NULL; | 107 | static char **contextargs = NULL; |
110 | char *context = NULL; | 108 | static char *context = NULL; |
111 | char **authpriv = NULL; | 109 | static char **authpriv = NULL; |
112 | char *proto = NULL; | 110 | static char *proto = NULL; |
113 | char *seclevel = NULL; | 111 | static char *seclevel = NULL; |
114 | char *secname = NULL; | 112 | static char *secname = NULL; |
115 | char *authproto = NULL; | 113 | static char *authproto = NULL; |
116 | char *privproto = NULL; | 114 | static char *privproto = NULL; |
117 | char *authpasswd = NULL; | 115 | static char *authpasswd = NULL; |
118 | char *privpasswd = NULL; | 116 | static char *privpasswd = NULL; |
119 | int nulloid = STATE_UNKNOWN; | 117 | static int nulloid = STATE_UNKNOWN; |
120 | char **oids = NULL; | 118 | static char **oids = NULL; |
121 | size_t oids_size = 0; | 119 | static size_t oids_size = 0; |
122 | char *label; | 120 | static char *label; |
123 | char *units; | 121 | static char *units; |
124 | char *port; | 122 | static char *port; |
125 | char *snmpcmd; | 123 | static char *snmpcmd; |
126 | char string_value[MAX_INPUT_BUFFER] = ""; | 124 | static char string_value[MAX_INPUT_BUFFER] = ""; |
127 | int invert_search=0; | 125 | static int invert_search=0; |
128 | char **labels = NULL; | 126 | static char **labels = NULL; |
129 | char **unitv = NULL; | 127 | static char **unitv = NULL; |
130 | size_t nlabels = 0; | 128 | static size_t nlabels = 0; |
131 | size_t labels_size = OID_COUNT_STEP; | 129 | static size_t labels_size = OID_COUNT_STEP; |
132 | size_t nunits = 0; | 130 | static size_t nunits = 0; |
133 | size_t unitv_size = OID_COUNT_STEP; | 131 | static size_t unitv_size = OID_COUNT_STEP; |
134 | size_t numoids = 0; | 132 | static size_t numoids = 0; |
135 | int numauthpriv = 0; | 133 | static int numauthpriv = 0; |
136 | int numcontext = 0; | 134 | static int numcontext = 0; |
137 | int verbose = 0; | 135 | static int verbose = 0; |
138 | bool usesnmpgetnext = false; | 136 | static bool usesnmpgetnext = false; |
139 | char *warning_thresholds = NULL; | 137 | static char *warning_thresholds = NULL; |
140 | char *critical_thresholds = NULL; | 138 | static char *critical_thresholds = NULL; |
141 | thresholds **thlds; | 139 | static thresholds **thlds; |
142 | size_t thlds_size = OID_COUNT_STEP; | 140 | static size_t thlds_size = OID_COUNT_STEP; |
143 | double *response_value; | 141 | static double *response_value; |
144 | size_t response_size = OID_COUNT_STEP; | 142 | static size_t response_size = OID_COUNT_STEP; |
145 | int retries = 0; | 143 | static int retries = 0; |
146 | int *eval_method; | 144 | static int *eval_method; |
147 | size_t eval_size = OID_COUNT_STEP; | 145 | static size_t eval_size = OID_COUNT_STEP; |
148 | char *delimiter; | 146 | static char *delimiter; |
149 | char *output_delim; | 147 | static char *output_delim; |
150 | char *miblist = NULL; | 148 | static char *miblist = NULL; |
151 | bool needmibs = false; | 149 | static bool needmibs = false; |
152 | int calculate_rate = 0; | 150 | static int calculate_rate = 0; |
153 | double offset = 0.0; | 151 | static double offset = 0.0; |
154 | int rate_multiplier = 1; | 152 | static int rate_multiplier = 1; |
155 | state_data *previous_state; | 153 | static state_data *previous_state; |
156 | double *previous_value; | 154 | static double *previous_value; |
157 | size_t previous_size = OID_COUNT_STEP; | 155 | static size_t previous_size = OID_COUNT_STEP; |
158 | int perf_labels = 1; | 156 | static int perf_labels = 1; |
159 | char* ip_version = ""; | 157 | static char* ip_version = ""; |
160 | double multiplier = 1.0; | 158 | static double multiplier = 1.0; |
161 | char *fmtstr = ""; | 159 | static char *fmtstr = ""; |
162 | bool fmtstr_set = false; | 160 | static bool fmtstr_set = false; |
163 | char buffer[DEFAULT_BUFFER_SIZE]; | 161 | static char buffer[DEFAULT_BUFFER_SIZE]; |
164 | bool ignore_mib_parsing_errors = false; | 162 | static bool ignore_mib_parsing_errors = false; |
165 | 163 | ||
166 | static char *fix_snmp_range(char *th) | 164 | static char *fix_snmp_range(char *th) |
167 | { | 165 | { |
@@ -1030,7 +1028,7 @@ selected.</para> | |||
1030 | 1028 | ||
1031 | 1029 | ||
1032 | 1030 | ||
1033 | int | 1031 | static int |
1034 | validate_arguments () | 1032 | validate_arguments () |
1035 | { | 1033 | { |
1036 | /* check whether to load locally installed MIBS (CPU/disk intensive) */ | 1034 | /* check whether to load locally installed MIBS (CPU/disk intensive) */ |
@@ -1139,7 +1137,7 @@ validate_arguments () | |||
1139 | /* trim leading whitespace | 1137 | /* trim leading whitespace |
1140 | if there is a leading quote, make sure it balances */ | 1138 | if there is a leading quote, make sure it balances */ |
1141 | 1139 | ||
1142 | char * | 1140 | static char * |
1143 | thisarg (char *str) | 1141 | thisarg (char *str) |
1144 | { | 1142 | { |
1145 | str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ | 1143 | str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ |
@@ -1156,7 +1154,7 @@ thisarg (char *str) | |||
1156 | set the trailing quote to '\x0' | 1154 | set the trailing quote to '\x0' |
1157 | if the string continues, advance beyond the comma */ | 1155 | if the string continues, advance beyond the comma */ |
1158 | 1156 | ||
1159 | char * | 1157 | static char * |
1160 | nextarg (char *str) | 1158 | nextarg (char *str) |
1161 | { | 1159 | { |
1162 | if (str[0] == '\'') { | 1160 | if (str[0] == '\'') { |
@@ -1188,7 +1186,7 @@ nextarg (char *str) | |||
1188 | 1186 | ||
1189 | 1187 | ||
1190 | /* multiply result (values 0 < n < 1 work as divider) */ | 1188 | /* multiply result (values 0 < n < 1 work as divider) */ |
1191 | char * | 1189 | static char * |
1192 | multiply (char *str) | 1190 | multiply (char *str) |
1193 | { | 1191 | { |
1194 | char *endptr; | 1192 | char *endptr; |
@@ -1225,7 +1223,7 @@ multiply (char *str) | |||
1225 | } | 1223 | } |
1226 | 1224 | ||
1227 | 1225 | ||
1228 | void | 1226 | static void |
1229 | print_help (void) | 1227 | print_help (void) |
1230 | { | 1228 | { |
1231 | print_revision (progname, NP_VERSION); | 1229 | print_revision (progname, NP_VERSION); |
@@ -1253,10 +1251,12 @@ print_help (void) | |||
1253 | printf (" %s\n", _("SNMPv3 context")); | 1251 | printf (" %s\n", _("SNMPv3 context")); |
1254 | printf (" %s\n", "-L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]"); | 1252 | printf (" %s\n", "-L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]"); |
1255 | printf (" %s\n", _("SNMPv3 securityLevel")); | 1253 | printf (" %s\n", _("SNMPv3 securityLevel")); |
1256 | printf (" %s\n", "-a, --authproto=[MD5|SHA]"); | 1254 | printf (" %s\n", "-a, --authproto=AUTHENTICATION_PROTOCOL"); |
1257 | printf (" %s\n", _("SNMPv3 auth proto")); | 1255 | printf (" %s\n", _("SNMPv3 authentication protocol (default MD5), available options depend on the specific version of the net-snmp tools")); |
1258 | printf (" %s\n", "-x, --privproto=[DES|AES]"); | 1256 | printf (" %s\n", _("if < 5.8 SHA (1) and MD5 should be available, if >= 5.8 additionally SHA-224, SHA-256, SHA-384 and SHA-512")); |
1259 | printf (" %s\n", _("SNMPv3 priv proto (default DES)")); | 1257 | printf (" %s\n", "-x, --privproto=PRIVACY_PROTOCOL"); |
1258 | printf (" %s\n", _("SNMPv3 privacy protocol (default DES), available options depend on the specific version of the net-snmp tools")); | ||
1259 | printf (" %s\n", _("if < 5.8 DES and AES should be available, if >= 5.8 additionally AES-192 and AES-256")); | ||
1260 | 1260 | ||
1261 | /* Authentication Tokens*/ | 1261 | /* Authentication Tokens*/ |
1262 | printf (" %s\n", "-C, --community=STRING"); | 1262 | printf (" %s\n", "-C, --community=STRING"); |