diff options
Diffstat (limited to 'plugins')
44 files changed, 223 insertions, 115 deletions
diff --git a/plugins/check_apt.c b/plugins/check_apt.c index 8747f90..a639a41 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c | |||
@@ -160,10 +160,10 @@ int process_arguments (int argc, char **argv) { | |||
160 | switch(c) { | 160 | switch(c) { |
161 | case 'h': | 161 | case 'h': |
162 | print_help(); | 162 | print_help(); |
163 | exit(STATE_OK); | 163 | exit(STATE_UNKNOWN); |
164 | case 'V': | 164 | case 'V': |
165 | print_revision(progname, NP_VERSION); | 165 | print_revision(progname, NP_VERSION); |
166 | exit(STATE_OK); | 166 | exit(STATE_UNKNOWN); |
167 | case 'v': | 167 | case 'v': |
168 | verbose++; | 168 | verbose++; |
169 | break; | 169 | break; |
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index a877f88..04bce38 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
@@ -209,10 +209,10 @@ process_arguments (int argc, char **argv) | |||
209 | switch (c) { | 209 | switch (c) { |
210 | case 'V': /* version */ | 210 | case 'V': /* version */ |
211 | print_revision (progname, NP_VERSION); | 211 | print_revision (progname, NP_VERSION); |
212 | exit (STATE_OK); | 212 | exit (STATE_UNKNOWN); |
213 | case 'h': /* help */ | 213 | case 'h': /* help */ |
214 | print_help (); | 214 | print_help (); |
215 | exit (STATE_OK); | 215 | exit (STATE_UNKNOWN); |
216 | case 'v': /* help */ | 216 | case 'v': /* help */ |
217 | verbose = TRUE; | 217 | verbose = TRUE; |
218 | break; | 218 | break; |
diff --git a/plugins/check_cluster.c b/plugins/check_cluster.c index cf699e1..b86e501 100644 --- a/plugins/check_cluster.c +++ b/plugins/check_cluster.c | |||
@@ -200,7 +200,7 @@ int process_arguments(int argc, char **argv){ | |||
200 | 200 | ||
201 | case 'V': /* version */ | 201 | case 'V': /* version */ |
202 | print_revision (progname, NP_VERSION); | 202 | print_revision (progname, NP_VERSION); |
203 | exit (STATE_OK); | 203 | exit (STATE_UNKNOWN); |
204 | break; | 204 | break; |
205 | 205 | ||
206 | case 'H': /* help */ | 206 | case 'H': /* help */ |
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c index a3d033f..826eb8d 100644 --- a/plugins/check_dbi.c +++ b/plugins/check_dbi.c | |||
@@ -368,10 +368,10 @@ process_arguments (int argc, char **argv) | |||
368 | usage5 (); | 368 | usage5 (); |
369 | case 'h': /* help */ | 369 | case 'h': /* help */ |
370 | print_help (); | 370 | print_help (); |
371 | exit (STATE_OK); | 371 | exit (STATE_UNKNOWN); |
372 | case 'V': /* version */ | 372 | case 'V': /* version */ |
373 | print_revision (progname, NP_VERSION); | 373 | print_revision (progname, NP_VERSION); |
374 | exit (STATE_OK); | 374 | exit (STATE_UNKNOWN); |
375 | 375 | ||
376 | case 'c': /* critical range */ | 376 | case 'c': /* critical range */ |
377 | critical_range = optarg; | 377 | critical_range = optarg; |
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index d899b11..db4b20e 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
@@ -223,10 +223,10 @@ process_arguments (int argc, char **argv) | |||
223 | switch (c) { | 223 | switch (c) { |
224 | case 'h': /* help */ | 224 | case 'h': /* help */ |
225 | print_help (); | 225 | print_help (); |
226 | exit (STATE_OK); | 226 | exit (STATE_UNKNOWN); |
227 | case 'V': /* version */ | 227 | case 'V': /* version */ |
228 | print_revision (progname, NP_VERSION); | 228 | print_revision (progname, NP_VERSION); |
229 | exit (STATE_OK); | 229 | exit (STATE_UNKNOWN); |
230 | case 'H': /* hostname */ | 230 | case 'H': /* hostname */ |
231 | host_or_die(optarg); | 231 | host_or_die(optarg); |
232 | dns_server = optarg; | 232 | dns_server = optarg; |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index eb573f5..9693bad 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -766,10 +766,10 @@ process_arguments (int argc, char **argv) | |||
766 | break; | 766 | break; |
767 | case 'V': /* version */ | 767 | case 'V': /* version */ |
768 | print_revision (progname, NP_VERSION); | 768 | print_revision (progname, NP_VERSION); |
769 | exit (STATE_OK); | 769 | exit (STATE_UNKNOWN); |
770 | case 'h': /* help */ | 770 | case 'h': /* help */ |
771 | print_help (); | 771 | print_help (); |
772 | exit (STATE_OK); | 772 | exit (STATE_UNKNOWN); |
773 | case '?': /* help */ | 773 | case '?': /* help */ |
774 | usage (_("Unknown argument")); | 774 | usage (_("Unknown argument")); |
775 | } | 775 | } |
diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 2212122..d6bd2c0 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c | |||
@@ -395,10 +395,10 @@ process_arguments (int argc, char **argv) | |||
395 | switch (c) { | 395 | switch (c) { |
396 | case 'h': /* help */ | 396 | case 'h': /* help */ |
397 | print_help (); | 397 | print_help (); |
398 | exit (STATE_OK); | 398 | exit (STATE_UNKNOWN); |
399 | case 'V': /* version */ | 399 | case 'V': /* version */ |
400 | print_revision (progname, NP_VERSION); | 400 | print_revision (progname, NP_VERSION); |
401 | exit (STATE_OK); | 401 | exit (STATE_UNKNOWN); |
402 | case 'v': /* version */ | 402 | case 'v': /* version */ |
403 | verbose = TRUE; | 403 | verbose = TRUE; |
404 | break; | 404 | break; |
diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c index 3ed6871..212a134 100644 --- a/plugins/check_dummy.c +++ b/plugins/check_dummy.c | |||
@@ -52,11 +52,11 @@ main (int argc, char **argv) | |||
52 | usage4 (_("Could not parse arguments")); | 52 | usage4 (_("Could not parse arguments")); |
53 | else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) { | 53 | else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) { |
54 | print_revision (progname, NP_VERSION); | 54 | print_revision (progname, NP_VERSION); |
55 | exit (STATE_OK); | 55 | exit (STATE_UNKNOWN); |
56 | } | 56 | } |
57 | else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) { | 57 | else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) { |
58 | print_help (); | 58 | print_help (); |
59 | exit (STATE_OK); | 59 | exit (STATE_UNKNOWN); |
60 | } | 60 | } |
61 | else if (!is_integer (argv[1])) | 61 | else if (!is_integer (argv[1])) |
62 | usage4 (_("Arguments to check_dummy must be an integer")); | 62 | usage4 (_("Arguments to check_dummy must be an integer")); |
diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 274dd75..da1ce1a 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c | |||
@@ -314,10 +314,10 @@ process_arguments (int argc, char **argv) | |||
314 | usage5 (); | 314 | usage5 (); |
315 | case 'h': /* help */ | 315 | case 'h': /* help */ |
316 | print_help (); | 316 | print_help (); |
317 | exit (STATE_OK); | 317 | exit (STATE_UNKNOWN); |
318 | case 'V': /* version */ | 318 | case 'V': /* version */ |
319 | print_revision (progname, NP_VERSION); | 319 | print_revision (progname, NP_VERSION); |
320 | exit (STATE_OK); | 320 | exit (STATE_UNKNOWN); |
321 | case 'v': /* verbose mode */ | 321 | case 'v': /* verbose mode */ |
322 | verbose = TRUE; | 322 | verbose = TRUE; |
323 | break; | 323 | break; |
diff --git a/plugins/check_game.c b/plugins/check_game.c index 29e59e2..709dae1 100644 --- a/plugins/check_game.c +++ b/plugins/check_game.c | |||
@@ -196,10 +196,10 @@ process_arguments (int argc, char **argv) | |||
196 | switch (c) { | 196 | switch (c) { |
197 | case 'h': /* help */ | 197 | case 'h': /* help */ |
198 | print_help (); | 198 | print_help (); |
199 | exit (STATE_OK); | 199 | exit (STATE_UNKNOWN); |
200 | case 'V': /* version */ | 200 | case 'V': /* version */ |
201 | print_revision (progname, NP_VERSION); | 201 | print_revision (progname, NP_VERSION); |
202 | exit (STATE_OK); | 202 | exit (STATE_UNKNOWN); |
203 | case 'v': /* version */ | 203 | case 'v': /* version */ |
204 | verbose = TRUE; | 204 | verbose = TRUE; |
205 | break; | 205 | break; |
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c index 5fe0698..f159f5a 100644 --- a/plugins/check_hpjd.c +++ b/plugins/check_hpjd.c | |||
@@ -350,10 +350,10 @@ process_arguments (int argc, char **argv) | |||
350 | break; | 350 | break; |
351 | case 'V': /* version */ | 351 | case 'V': /* version */ |
352 | print_revision (progname, NP_VERSION); | 352 | print_revision (progname, NP_VERSION); |
353 | exit (STATE_OK); | 353 | exit (STATE_UNKNOWN); |
354 | case 'h': /* help */ | 354 | case 'h': /* help */ |
355 | print_help (); | 355 | print_help (); |
356 | exit (STATE_OK); | 356 | exit (STATE_UNKNOWN); |
357 | case '?': /* help */ | 357 | case '?': /* help */ |
358 | usage5 (); | 358 | usage5 (); |
359 | } | 359 | } |
diff --git a/plugins/check_http.c b/plugins/check_http.c index b1a69e5..2038f4a 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -267,11 +267,11 @@ process_arguments (int argc, char **argv) | |||
267 | break; | 267 | break; |
268 | case 'h': /* help */ | 268 | case 'h': /* help */ |
269 | print_help (); | 269 | print_help (); |
270 | exit (STATE_OK); | 270 | exit (STATE_UNKNOWN); |
271 | break; | 271 | break; |
272 | case 'V': /* version */ | 272 | case 'V': /* version */ |
273 | print_revision (progname, NP_VERSION); | 273 | print_revision (progname, NP_VERSION); |
274 | exit (STATE_OK); | 274 | exit (STATE_UNKNOWN); |
275 | break; | 275 | break; |
276 | case 't': /* timeout period */ | 276 | case 't': /* timeout period */ |
277 | if (!is_intnonneg (optarg)) | 277 | if (!is_intnonneg (optarg)) |
@@ -880,17 +880,42 @@ check_http (void) | |||
880 | double elapsed_time_transfer = 0.0; | 880 | double elapsed_time_transfer = 0.0; |
881 | int page_len = 0; | 881 | int page_len = 0; |
882 | int result = STATE_OK; | 882 | int result = STATE_OK; |
883 | char *force_host_header = NULL; | ||
883 | 884 | ||
884 | /* try to connect to the host at the given port number */ | 885 | /* try to connect to the host at the given port number */ |
885 | gettimeofday (&tv_temp, NULL); | 886 | gettimeofday (&tv_temp, NULL); |
886 | if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) | 887 | if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) |
887 | die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n")); | 888 | die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n")); |
888 | microsec_connect = deltime (tv_temp); | 889 | microsec_connect = deltime (tv_temp); |
890 | |||
891 | /* if we are called with the -I option, the -j method is CONNECT and */ | ||
892 | /* we received -S for SSL, then we tunnel the request through a proxy*/ | ||
893 | /* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */ | ||
894 | |||
895 | if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 | ||
896 | && host_name != NULL && use_ssl == TRUE) { | ||
897 | |||
898 | if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); | ||
899 | asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); | ||
900 | asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf); | ||
901 | asprintf (&buf, "%sHost: %s\r\n", buf, host_name); | ||
902 | /* we finished our request, send empty line with CRLF */ | ||
903 | asprintf (&buf, "%s%s", buf, CRLF); | ||
904 | if (verbose) printf ("%s\n", buf); | ||
905 | send(sd, buf, strlen (buf), 0); | ||
906 | buf[0]='\0'; | ||
907 | |||
908 | if (verbose) printf ("Receive response from proxy\n"); | ||
909 | read (sd, buffer, MAX_INPUT_BUFFER-1); | ||
910 | if (verbose) printf ("%s", buffer); | ||
911 | /* Here we should check if we got HTTP/1.1 200 Connection established */ | ||
912 | } | ||
889 | #ifdef HAVE_SSL | 913 | #ifdef HAVE_SSL |
890 | elapsed_time_connect = (double)microsec_connect / 1.0e6; | 914 | elapsed_time_connect = (double)microsec_connect / 1.0e6; |
891 | if (use_ssl == TRUE) { | 915 | if (use_ssl == TRUE) { |
892 | gettimeofday (&tv_temp, NULL); | 916 | gettimeofday (&tv_temp, NULL); |
893 | result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey); | 917 | result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey); |
918 | if (verbose) printf ("SSL initialized\n"); | ||
894 | if (result != STATE_OK) | 919 | if (result != STATE_OK) |
895 | die (STATE_CRITICAL, NULL); | 920 | die (STATE_CRITICAL, NULL); |
896 | microsec_ssl = deltime (tv_temp); | 921 | microsec_ssl = deltime (tv_temp); |
@@ -904,29 +929,51 @@ check_http (void) | |||
904 | } | 929 | } |
905 | #endif /* HAVE_SSL */ | 930 | #endif /* HAVE_SSL */ |
906 | 931 | ||
907 | xasprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | 932 | if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 |
933 | && host_name != NULL && use_ssl == TRUE) | ||
934 | asprintf (&buf, "%s %s %s\r\n%s\r\n", "GET", server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | ||
935 | else | ||
936 | asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | ||
908 | 937 | ||
909 | /* tell HTTP/1.1 servers not to keep the connection alive */ | 938 | /* tell HTTP/1.1 servers not to keep the connection alive */ |
910 | xasprintf (&buf, "%sConnection: close\r\n", buf); | 939 | xasprintf (&buf, "%sConnection: close\r\n", buf); |
911 | 940 | ||
941 | /* check if Host header is explicitly set in options */ | ||
942 | if (http_opt_headers_count) { | ||
943 | for (i = 0; i < http_opt_headers_count ; i++) { | ||
944 | if (strncmp(http_opt_headers[i], "Host:", 5) == 0) { | ||
945 | force_host_header = http_opt_headers[i]; | ||
946 | } | ||
947 | } | ||
948 | } | ||
949 | |||
912 | /* optionally send the host header info */ | 950 | /* optionally send the host header info */ |
913 | if (host_name) { | 951 | if (host_name) { |
914 | /* | 952 | if (force_host_header) { |
915 | * Specify the port only if we're using a non-default port (see RFC 2616, | 953 | xasprintf (&buf, "%s%s\r\n", buf, force_host_header); |
916 | * 14.23). Some server applications/configurations cause trouble if the | 954 | } |
917 | * (default) port is explicitly specified in the "Host:" header line. | 955 | else { |
918 | */ | 956 | /* |
919 | if ((use_ssl == FALSE && server_port == HTTP_PORT) || | 957 | * Specify the port only if we're using a non-default port (see RFC 2616, |
920 | (use_ssl == TRUE && server_port == HTTPS_PORT)) | 958 | * 14.23). Some server applications/configurations cause trouble if the |
921 | xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); | 959 | * (default) port is explicitly specified in the "Host:" header line. |
922 | else | 960 | */ |
923 | xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); | 961 | if ((use_ssl == FALSE && server_port == HTTP_PORT) || |
962 | (use_ssl == TRUE && server_port == HTTPS_PORT) || | ||
963 | (server_address != NULL && strcmp(http_method, "CONNECT") == 0 | ||
964 | && host_name != NULL && use_ssl == TRUE)) | ||
965 | xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); | ||
966 | else | ||
967 | xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); | ||
968 | } | ||
924 | } | 969 | } |
925 | 970 | ||
926 | /* optionally send any other header tag */ | 971 | /* optionally send any other header tag */ |
927 | if (http_opt_headers_count) { | 972 | if (http_opt_headers_count) { |
928 | for (i = 0; i < http_opt_headers_count ; i++) { | 973 | for (i = 0; i < http_opt_headers_count ; i++) { |
929 | xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]); | 974 | if (force_host_header != http_opt_headers[i]) { |
975 | xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]); | ||
976 | } | ||
930 | } | 977 | } |
931 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ | 978 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ |
932 | /* Covered in a testcase in tests/check_http.t */ | 979 | /* Covered in a testcase in tests/check_http.t */ |
@@ -1508,7 +1555,7 @@ print_help (void) | |||
1508 | printf (" %s\n", _("URL to GET or POST (default: /)")); | 1555 | printf (" %s\n", _("URL to GET or POST (default: /)")); |
1509 | printf (" %s\n", "-P, --post=STRING"); | 1556 | printf (" %s\n", "-P, --post=STRING"); |
1510 | printf (" %s\n", _("URL encoded http POST data")); | 1557 | printf (" %s\n", _("URL encoded http POST data")); |
1511 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE)"); | 1558 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)"); |
1512 | printf (" %s\n", _("Set HTTP method.")); | 1559 | printf (" %s\n", _("Set HTTP method.")); |
1513 | printf (" %s\n", "-N, --no-body"); | 1560 | printf (" %s\n", "-N, --no-body"); |
1514 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); | 1561 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); |
@@ -1582,7 +1629,7 @@ print_help (void) | |||
1582 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,")); | 1629 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,")); |
1583 | printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); | 1630 | printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); |
1584 | printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when")); | 1631 | printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when")); |
1585 | printf (" %s\n", _("the certificate is expired.")); | 1632 | printf (" %s\n\n", _("the certificate is expired.")); |
1586 | printf ("\n"); | 1633 | printf ("\n"); |
1587 | printf (" %s\n\n", "CHECK CERTIFICATE: check_http -H www.verisign.com -C 30,14"); | 1634 | printf (" %s\n\n", "CHECK CERTIFICATE: check_http -H www.verisign.com -C 30,14"); |
1588 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 30 days,")); | 1635 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 30 days,")); |
@@ -1590,6 +1637,13 @@ print_help (void) | |||
1590 | printf (" %s\n", _("30 days, but more than 14 days, a STATE_WARNING is returned.")); | 1637 | printf (" %s\n", _("30 days, but more than 14 days, a STATE_WARNING is returned.")); |
1591 | printf (" %s\n", _("A STATE_CRITICAL will be returned when certificate expires in less than 14 days")); | 1638 | printf (" %s\n", _("A STATE_CRITICAL will be returned when certificate expires in less than 14 days")); |
1592 | 1639 | ||
1640 | printf (" %s\n\n", "CHECK SSL WEBSERVER CONTENT VIA PROXY USING HTTP 1.1 CONNECT: "); | ||
1641 | printf (" %s\n", _("check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j CONNECT -H www.verisign.com ")); | ||
1642 | printf (" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -S(sl) -j CONNECT -H <webserver>")); | ||
1643 | printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds")); | ||
1644 | printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,")); | ||
1645 | printf (" %s\n", _("a STATE_CRITICAL will be returned.")); | ||
1646 | |||
1593 | #endif | 1647 | #endif |
1594 | 1648 | ||
1595 | printf (UT_SUPPORT); | 1649 | printf (UT_SUPPORT); |
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 47605e9..8d540ca 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c | |||
@@ -234,10 +234,10 @@ main (int argc, char *argv[]) | |||
234 | break; | 234 | break; |
235 | case 'h': | 235 | case 'h': |
236 | print_help (); | 236 | print_help (); |
237 | return STATE_OK; | 237 | return STATE_UNKNOWN; |
238 | case 'V': | 238 | case 'V': |
239 | print_revision (progname, NP_VERSION); | 239 | print_revision (progname, NP_VERSION); |
240 | return STATE_OK; | 240 | return STATE_UNKNOWN; |
241 | default: | 241 | default: |
242 | usage5 (); | 242 | usage5 (); |
243 | } | 243 | } |
@@ -249,7 +249,7 @@ main (int argc, char *argv[]) | |||
249 | 249 | ||
250 | if (!device) { | 250 | if (!device) { |
251 | print_help (); | 251 | print_help (); |
252 | return STATE_OK; | 252 | return STATE_UNKNOWN; |
253 | } | 253 | } |
254 | 254 | ||
255 | fd = open (device, OPEN_MODE); | 255 | fd = open (device, OPEN_MODE); |
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index cfc8222..e70d6a5 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c | |||
@@ -325,10 +325,10 @@ process_arguments (int argc, char **argv) | |||
325 | switch (c) { | 325 | switch (c) { |
326 | case 'h': /* help */ | 326 | case 'h': /* help */ |
327 | print_help (); | 327 | print_help (); |
328 | exit (STATE_OK); | 328 | exit (STATE_UNKNOWN); |
329 | case 'V': /* version */ | 329 | case 'V': /* version */ |
330 | print_revision (progname, NP_VERSION); | 330 | print_revision (progname, NP_VERSION); |
331 | exit (STATE_OK); | 331 | exit (STATE_UNKNOWN); |
332 | case 't': /* timeout period */ | 332 | case 't': /* timeout period */ |
333 | if (!is_intnonneg (optarg)) | 333 | if (!is_intnonneg (optarg)) |
334 | usage2 (_("Timeout interval must be a positive integer"), optarg); | 334 | usage2 (_("Timeout interval must be a positive integer"), optarg); |
diff --git a/plugins/check_load.c b/plugins/check_load.c index cde63e5..a96435f 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c | |||
@@ -251,10 +251,10 @@ process_arguments (int argc, char **argv) | |||
251 | break; | 251 | break; |
252 | case 'V': /* version */ | 252 | case 'V': /* version */ |
253 | print_revision (progname, NP_VERSION); | 253 | print_revision (progname, NP_VERSION); |
254 | exit (STATE_OK); | 254 | exit (STATE_UNKNOWN); |
255 | case 'h': /* help */ | 255 | case 'h': /* help */ |
256 | print_help (); | 256 | print_help (); |
257 | exit (STATE_OK); | 257 | exit (STATE_UNKNOWN); |
258 | case '?': /* help */ | 258 | case '?': /* help */ |
259 | usage5 (); | 259 | usage5 (); |
260 | } | 260 | } |
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c index cf3fe04..1fda549 100644 --- a/plugins/check_mrtg.c +++ b/plugins/check_mrtg.c | |||
@@ -234,10 +234,10 @@ process_arguments (int argc, char **argv) | |||
234 | break; | 234 | break; |
235 | case 'V': /* version */ | 235 | case 'V': /* version */ |
236 | print_revision (progname, NP_VERSION); | 236 | print_revision (progname, NP_VERSION); |
237 | exit (STATE_OK); | 237 | exit (STATE_UNKNOWN); |
238 | case 'h': /* help */ | 238 | case 'h': /* help */ |
239 | print_help (); | 239 | print_help (); |
240 | exit (STATE_OK); | 240 | exit (STATE_UNKNOWN); |
241 | case '?': /* help */ | 241 | case '?': /* help */ |
242 | usage5 (); | 242 | usage5 (); |
243 | } | 243 | } |
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c index 3b038cf..eb66f62 100644 --- a/plugins/check_mrtgtraf.c +++ b/plugins/check_mrtgtraf.c | |||
@@ -270,10 +270,10 @@ process_arguments (int argc, char **argv) | |||
270 | break; | 270 | break; |
271 | case 'V': /* version */ | 271 | case 'V': /* version */ |
272 | print_revision (progname, NP_VERSION); | 272 | print_revision (progname, NP_VERSION); |
273 | exit (STATE_OK); | 273 | exit (STATE_UNKNOWN); |
274 | case 'h': /* help */ | 274 | case 'h': /* help */ |
275 | print_help (); | 275 | print_help (); |
276 | exit (STATE_OK); | 276 | exit (STATE_UNKNOWN); |
277 | case '?': /* help */ | 277 | case '?': /* help */ |
278 | usage5 (); | 278 | usage5 (); |
279 | } | 279 | } |
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 216626b..5773afd 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
@@ -444,10 +444,10 @@ process_arguments (int argc, char **argv) | |||
444 | break; | 444 | break; |
445 | case 'V': /* version */ | 445 | case 'V': /* version */ |
446 | print_revision (progname, NP_VERSION); | 446 | print_revision (progname, NP_VERSION); |
447 | exit (STATE_OK); | 447 | exit (STATE_UNKNOWN); |
448 | case 'h': /* help */ | 448 | case 'h': /* help */ |
449 | print_help (); | 449 | print_help (); |
450 | exit (STATE_OK); | 450 | exit (STATE_UNKNOWN); |
451 | case 'v': | 451 | case 'v': |
452 | verbose++; | 452 | verbose++; |
453 | break; | 453 | break; |
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c index 71ab776..49a14dd 100644 --- a/plugins/check_mysql_query.c +++ b/plugins/check_mysql_query.c | |||
@@ -250,10 +250,10 @@ process_arguments (int argc, char **argv) | |||
250 | break; | 250 | break; |
251 | case 'V': /* version */ | 251 | case 'V': /* version */ |
252 | print_revision (progname, NP_VERSION); | 252 | print_revision (progname, NP_VERSION); |
253 | exit (STATE_OK); | 253 | exit (STATE_UNKNOWN); |
254 | case 'h': /* help */ | 254 | case 'h': /* help */ |
255 | print_help (); | 255 | print_help (); |
256 | exit (STATE_OK); | 256 | exit (STATE_UNKNOWN); |
257 | case 'q': | 257 | case 'q': |
258 | xasprintf(&sql_query, "%s", optarg); | 258 | xasprintf(&sql_query, "%s", optarg); |
259 | break; | 259 | break; |
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 791b6db..40d68f0 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c | |||
@@ -235,10 +235,10 @@ process_arguments (int argc, char **argv) | |||
235 | switch (c) { | 235 | switch (c) { |
236 | case 'h': /* help */ | 236 | case 'h': /* help */ |
237 | print_help (); | 237 | print_help (); |
238 | exit (STATE_OK); | 238 | exit (STATE_UNKNOWN); |
239 | case 'V': /* version */ | 239 | case 'V': /* version */ |
240 | print_revision (progname, NP_VERSION); | 240 | print_revision (progname, NP_VERSION); |
241 | exit (STATE_OK); | 241 | exit (STATE_UNKNOWN); |
242 | case 'F': /* status log */ | 242 | case 'F': /* status log */ |
243 | status_log = optarg; | 243 | status_log = optarg; |
244 | break; | 244 | break; |
diff --git a/plugins/check_nt.c b/plugins/check_nt.c index f621b0a..59c135d 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c | |||
@@ -553,10 +553,10 @@ int process_arguments(int argc, char **argv){ | |||
553 | usage5 (); | 553 | usage5 (); |
554 | case 'h': /* help */ | 554 | case 'h': /* help */ |
555 | print_help(); | 555 | print_help(); |
556 | exit(STATE_OK); | 556 | exit(STATE_UNKNOWN); |
557 | case 'V': /* version */ | 557 | case 'V': /* version */ |
558 | print_revision(progname, NP_VERSION); | 558 | print_revision(progname, NP_VERSION); |
559 | exit(STATE_OK); | 559 | exit(STATE_UNKNOWN); |
560 | case 'H': /* hostname */ | 560 | case 'H': /* hostname */ |
561 | server_address = optarg; | 561 | server_address = optarg; |
562 | break; | 562 | break; |
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index a7d278d..75efc28 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c | |||
@@ -691,11 +691,11 @@ int process_arguments(int argc, char **argv){ | |||
691 | switch (c) { | 691 | switch (c) { |
692 | case 'h': | 692 | case 'h': |
693 | print_help(); | 693 | print_help(); |
694 | exit(STATE_OK); | 694 | exit(STATE_UNKNOWN); |
695 | break; | 695 | break; |
696 | case 'V': | 696 | case 'V': |
697 | print_revision(progname, NP_VERSION); | 697 | print_revision(progname, NP_VERSION); |
698 | exit(STATE_OK); | 698 | exit(STATE_UNKNOWN); |
699 | break; | 699 | break; |
700 | case 'v': | 700 | case 'v': |
701 | verbose++; | 701 | verbose++; |
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index 44424af..c656b0f 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c | |||
@@ -448,11 +448,11 @@ int process_arguments(int argc, char **argv){ | |||
448 | switch (c) { | 448 | switch (c) { |
449 | case 'h': | 449 | case 'h': |
450 | print_help(); | 450 | print_help(); |
451 | exit(STATE_OK); | 451 | exit(STATE_UNKNOWN); |
452 | break; | 452 | break; |
453 | case 'V': | 453 | case 'V': |
454 | print_revision(progname, NP_VERSION); | 454 | print_revision(progname, NP_VERSION); |
455 | exit(STATE_OK); | 455 | exit(STATE_UNKNOWN); |
456 | break; | 456 | break; |
457 | case 'v': | 457 | case 'v': |
458 | verbose++; | 458 | verbose++; |
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index e344f8b..295f86f 100644 --- a/plugins/check_ntp_time.c +++ b/plugins/check_ntp_time.c | |||
@@ -477,11 +477,11 @@ int process_arguments(int argc, char **argv){ | |||
477 | switch (c) { | 477 | switch (c) { |
478 | case 'h': | 478 | case 'h': |
479 | print_help(); | 479 | print_help(); |
480 | exit(STATE_OK); | 480 | exit(STATE_UNKNOWN); |
481 | break; | 481 | break; |
482 | case 'V': | 482 | case 'V': |
483 | print_revision(progname, NP_VERSION); | 483 | print_revision(progname, NP_VERSION); |
484 | exit(STATE_OK); | 484 | exit(STATE_UNKNOWN); |
485 | break; | 485 | break; |
486 | case 'v': | 486 | case 'v': |
487 | verbose++; | 487 | verbose++; |
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index 1a7bfa1..e7e8de0 100644 --- a/plugins/check_nwstat.c +++ b/plugins/check_nwstat.c | |||
@@ -1354,10 +1354,10 @@ int process_arguments(int argc, char **argv) { | |||
1354 | usage5 (); | 1354 | usage5 (); |
1355 | case 'h': /* help */ | 1355 | case 'h': /* help */ |
1356 | print_help(); | 1356 | print_help(); |
1357 | exit(STATE_OK); | 1357 | exit(STATE_UNKNOWN); |
1358 | case 'V': /* version */ | 1358 | case 'V': /* version */ |
1359 | print_revision(progname, NP_VERSION); | 1359 | print_revision(progname, NP_VERSION); |
1360 | exit(STATE_OK); | 1360 | exit(STATE_UNKNOWN); |
1361 | case 'H': /* hostname */ | 1361 | case 'H': /* hostname */ |
1362 | server_address=optarg; | 1362 | server_address=optarg; |
1363 | break; | 1363 | break; |
diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c index af5eb9b..9a4d25f 100644 --- a/plugins/check_overcr.c +++ b/plugins/check_overcr.c | |||
@@ -340,10 +340,10 @@ process_arguments (int argc, char **argv) | |||
340 | usage5 (); | 340 | usage5 (); |
341 | case 'h': /* help */ | 341 | case 'h': /* help */ |
342 | print_help (); | 342 | print_help (); |
343 | exit (STATE_OK); | 343 | exit (STATE_UNKNOWN); |
344 | case 'V': /* version */ | 344 | case 'V': /* version */ |
345 | print_revision (progname, NP_VERSION); | 345 | print_revision (progname, NP_VERSION); |
346 | exit (STATE_OK); | 346 | exit (STATE_UNKNOWN); |
347 | case 'H': /* hostname */ | 347 | case 'H': /* hostname */ |
348 | server_address = optarg; | 348 | server_address = optarg; |
349 | break; | 349 | break; |
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 9bad1ec..2eb699e 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c | |||
@@ -302,10 +302,10 @@ process_arguments (int argc, char **argv) | |||
302 | usage5 (); | 302 | usage5 (); |
303 | case 'h': /* help */ | 303 | case 'h': /* help */ |
304 | print_help (); | 304 | print_help (); |
305 | exit (STATE_OK); | 305 | exit (STATE_UNKNOWN); |
306 | case 'V': /* version */ | 306 | case 'V': /* version */ |
307 | print_revision (progname, NP_VERSION); | 307 | print_revision (progname, NP_VERSION); |
308 | exit (STATE_OK); | 308 | exit (STATE_UNKNOWN); |
309 | case 't': /* timeout period */ | 309 | case 't': /* timeout period */ |
310 | if (!is_integer (optarg)) | 310 | if (!is_integer (optarg)) |
311 | usage2 (_("Timeout interval must be a positive integer"), optarg); | 311 | usage2 (_("Timeout interval must be a positive integer"), optarg); |
diff --git a/plugins/check_ping.c b/plugins/check_ping.c index dbc5c3e..423ecbe 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c | |||
@@ -224,11 +224,11 @@ process_arguments (int argc, char **argv) | |||
224 | usage5 (); | 224 | usage5 (); |
225 | case 'h': /* help */ | 225 | case 'h': /* help */ |
226 | print_help (); | 226 | print_help (); |
227 | exit (STATE_OK); | 227 | exit (STATE_UNKNOWN); |
228 | break; | 228 | break; |
229 | case 'V': /* version */ | 229 | case 'V': /* version */ |
230 | print_revision (progname, NP_VERSION); | 230 | print_revision (progname, NP_VERSION); |
231 | exit (STATE_OK); | 231 | exit (STATE_UNKNOWN); |
232 | break; | 232 | break; |
233 | case 't': /* timeout period */ | 233 | case 't': /* timeout period */ |
234 | timeout_interval = atoi (optarg); | 234 | timeout_interval = atoi (optarg); |
diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 402aac5..4bcc56b 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c | |||
@@ -428,10 +428,10 @@ process_arguments (int argc, char **argv) | |||
428 | usage5 (); | 428 | usage5 (); |
429 | case 'h': /* help */ | 429 | case 'h': /* help */ |
430 | print_help (); | 430 | print_help (); |
431 | exit (STATE_OK); | 431 | exit (STATE_UNKNOWN); |
432 | case 'V': /* version */ | 432 | case 'V': /* version */ |
433 | print_revision (progname, NP_VERSION); | 433 | print_revision (progname, NP_VERSION); |
434 | exit (STATE_OK); | 434 | exit (STATE_UNKNOWN); |
435 | case 't': /* timeout period */ | 435 | case 't': /* timeout period */ |
436 | if (!is_integer (optarg)) | 436 | if (!is_integer (optarg)) |
437 | usage2 (_("Timeout interval must be a positive integer"), optarg); | 437 | usage2 (_("Timeout interval must be a positive integer"), optarg); |
diff --git a/plugins/check_radius.c b/plugins/check_radius.c index b294347..03cbb8b 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c | |||
@@ -259,10 +259,10 @@ process_arguments (int argc, char **argv) | |||
259 | usage5 (); | 259 | usage5 (); |
260 | case 'h': /* help */ | 260 | case 'h': /* help */ |
261 | print_help (); | 261 | print_help (); |
262 | exit (OK); | 262 | exit (STATE_UNKNOWN); |
263 | case 'V': /* version */ | 263 | case 'V': /* version */ |
264 | print_revision (progname, NP_VERSION); | 264 | print_revision (progname, NP_VERSION); |
265 | exit (OK); | 265 | exit (STATE_UNKNOWN); |
266 | case 'v': /* verbose mode */ | 266 | case 'v': /* verbose mode */ |
267 | verbose = TRUE; | 267 | verbose = TRUE; |
268 | break; | 268 | break; |
diff --git a/plugins/check_real.c b/plugins/check_real.c index 00bd4d2..6491e6e 100644 --- a/plugins/check_real.c +++ b/plugins/check_real.c | |||
@@ -359,10 +359,10 @@ process_arguments (int argc, char **argv) | |||
359 | break; | 359 | break; |
360 | case 'V': /* version */ | 360 | case 'V': /* version */ |
361 | print_revision (progname, NP_VERSION); | 361 | print_revision (progname, NP_VERSION); |
362 | exit (STATE_OK); | 362 | exit (STATE_UNKNOWN); |
363 | case 'h': /* help */ | 363 | case 'h': /* help */ |
364 | print_help (); | 364 | print_help (); |
365 | exit (STATE_OK); | 365 | exit (STATE_UNKNOWN); |
366 | case '?': /* usage */ | 366 | case '?': /* usage */ |
367 | usage5 (); | 367 | usage5 (); |
368 | } | 368 | } |
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 2430453..56040ff 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
@@ -623,10 +623,10 @@ process_arguments (int argc, char **argv) | |||
623 | break; | 623 | break; |
624 | case 'V': /* version */ | 624 | case 'V': /* version */ |
625 | print_revision (progname, NP_VERSION); | 625 | print_revision (progname, NP_VERSION); |
626 | exit (STATE_OK); | 626 | exit (STATE_UNKNOWN); |
627 | case 'h': /* help */ | 627 | case 'h': /* help */ |
628 | print_help (); | 628 | print_help (); |
629 | exit (STATE_OK); | 629 | exit (STATE_UNKNOWN); |
630 | case '?': /* help */ | 630 | case '?': /* help */ |
631 | usage5 (); | 631 | usage5 (); |
632 | } | 632 | } |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 62e6b8b..28cc44d 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -709,10 +709,10 @@ process_arguments (int argc, char **argv) | |||
709 | usage5 (); | 709 | usage5 (); |
710 | case 'h': /* help */ | 710 | case 'h': /* help */ |
711 | print_help (); | 711 | print_help (); |
712 | exit (STATE_OK); | 712 | exit (STATE_UNKNOWN); |
713 | case 'V': /* version */ | 713 | case 'V': /* version */ |
714 | print_revision (progname, NP_VERSION); | 714 | print_revision (progname, NP_VERSION); |
715 | exit (STATE_OK); | 715 | exit (STATE_UNKNOWN); |
716 | case 'v': /* verbose */ | 716 | case 'v': /* verbose */ |
717 | verbose++; | 717 | verbose++; |
718 | break; | 718 | break; |
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c index 3658965..8ccbd5a 100644 --- a/plugins/check_ssh.c +++ b/plugins/check_ssh.c | |||
@@ -128,10 +128,10 @@ process_arguments (int argc, char **argv) | |||
128 | usage5 (); | 128 | usage5 (); |
129 | case 'V': /* version */ | 129 | case 'V': /* version */ |
130 | print_revision (progname, NP_VERSION); | 130 | print_revision (progname, NP_VERSION); |
131 | exit (STATE_OK); | 131 | exit (STATE_UNKNOWN); |
132 | case 'h': /* help */ | 132 | case 'h': /* help */ |
133 | print_help (); | 133 | print_help (); |
134 | exit (STATE_OK); | 134 | exit (STATE_UNKNOWN); |
135 | case 'v': /* verbose */ | 135 | case 'v': /* verbose */ |
136 | verbose = TRUE; | 136 | verbose = TRUE; |
137 | break; | 137 | break; |
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 25e0bac..4d5a407 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
@@ -470,10 +470,10 @@ process_arguments (int argc, char **argv) | |||
470 | break; | 470 | break; |
471 | case 'V': /* version */ | 471 | case 'V': /* version */ |
472 | print_revision (progname, NP_VERSION); | 472 | print_revision (progname, NP_VERSION); |
473 | exit (STATE_OK); | 473 | exit (STATE_UNKNOWN); |
474 | case 'h': /* help */ | 474 | case 'h': /* help */ |
475 | print_help (); | 475 | print_help (); |
476 | exit (STATE_OK); | 476 | exit (STATE_UNKNOWN); |
477 | case '?': /* error */ | 477 | case '?': /* error */ |
478 | usage5 (); | 478 | usage5 (); |
479 | } | 479 | } |
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index a18c37a..6dc9aa9 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
@@ -237,7 +237,7 @@ main (int argc, char **argv) | |||
237 | gettimeofday (&tv, NULL); | 237 | gettimeofday (&tv, NULL); |
238 | 238 | ||
239 | result = np_net_connect (server_address, server_port, &sd, PROTOCOL); | 239 | result = np_net_connect (server_address, server_port, &sd, PROTOCOL); |
240 | if (result == STATE_CRITICAL) return STATE_CRITICAL; | 240 | if (result == STATE_CRITICAL) return econn_refuse_state; |
241 | 241 | ||
242 | #ifdef HAVE_SSL | 242 | #ifdef HAVE_SSL |
243 | if (flags & FLAG_SSL){ | 243 | if (flags & FLAG_SSL){ |
@@ -463,10 +463,10 @@ process_arguments (int argc, char **argv) | |||
463 | usage5 (); | 463 | usage5 (); |
464 | case 'h': /* help */ | 464 | case 'h': /* help */ |
465 | print_help (); | 465 | print_help (); |
466 | exit (STATE_OK); | 466 | exit (STATE_UNKNOWN); |
467 | case 'V': /* version */ | 467 | case 'V': /* version */ |
468 | print_revision (progname, NP_VERSION); | 468 | print_revision (progname, NP_VERSION); |
469 | exit (STATE_OK); | 469 | exit (STATE_UNKNOWN); |
470 | case 'v': /* verbose mode */ | 470 | case 'v': /* verbose mode */ |
471 | flags |= FLAG_VERBOSE; | 471 | flags |= FLAG_VERBOSE; |
472 | match_flags |= NP_MATCH_VERBOSE; | 472 | match_flags |= NP_MATCH_VERBOSE; |
diff --git a/plugins/check_time.c b/plugins/check_time.c index 3943742..baf8c59 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c | |||
@@ -231,10 +231,10 @@ process_arguments (int argc, char **argv) | |||
231 | usage5 (); | 231 | usage5 (); |
232 | case 'h': /* help */ | 232 | case 'h': /* help */ |
233 | print_help (); | 233 | print_help (); |
234 | exit (STATE_OK); | 234 | exit (STATE_UNKNOWN); |
235 | case 'V': /* version */ | 235 | case 'V': /* version */ |
236 | print_revision (progname, NP_VERSION); | 236 | print_revision (progname, NP_VERSION); |
237 | exit (STATE_OK); | 237 | exit (STATE_UNKNOWN); |
238 | case 'H': /* hostname */ | 238 | case 'H': /* hostname */ |
239 | if (is_host (optarg) == FALSE) | 239 | if (is_host (optarg) == FALSE) |
240 | usage2 (_("Invalid hostname/address"), optarg); | 240 | usage2 (_("Invalid hostname/address"), optarg); |
diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 099881d..dc5a348 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c | |||
@@ -558,10 +558,10 @@ process_arguments (int argc, char **argv) | |||
558 | break; | 558 | break; |
559 | case 'V': /* version */ | 559 | case 'V': /* version */ |
560 | print_revision (progname, NP_VERSION); | 560 | print_revision (progname, NP_VERSION); |
561 | exit (STATE_OK); | 561 | exit (STATE_UNKNOWN); |
562 | case 'h': /* help */ | 562 | case 'h': /* help */ |
563 | print_help (); | 563 | print_help (); |
564 | exit (STATE_OK); | 564 | exit (STATE_UNKNOWN); |
565 | } | 565 | } |
566 | } | 566 | } |
567 | 567 | ||
diff --git a/plugins/check_users.c b/plugins/check_users.c index a009f20..54415a4 100644 --- a/plugins/check_users.c +++ b/plugins/check_users.c | |||
@@ -210,10 +210,10 @@ process_arguments (int argc, char **argv) | |||
210 | usage5 (); | 210 | usage5 (); |
211 | case 'h': /* help */ | 211 | case 'h': /* help */ |
212 | print_help (); | 212 | print_help (); |
213 | exit (STATE_OK); | 213 | exit (STATE_UNKNOWN); |
214 | case 'V': /* version */ | 214 | case 'V': /* version */ |
215 | print_revision (progname, NP_VERSION); | 215 | print_revision (progname, NP_VERSION); |
216 | exit (STATE_OK); | 216 | exit (STATE_UNKNOWN); |
217 | case 'c': /* critical */ | 217 | case 'c': /* critical */ |
218 | if (!is_intnonneg (optarg)) | 218 | if (!is_intnonneg (optarg)) |
219 | usage4 (_("Critical threshold must be a positive integer")); | 219 | usage4 (_("Critical threshold must be a positive integer")); |
diff --git a/plugins/netutils.c b/plugins/netutils.c index 83f8942..705aaf0 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c | |||
@@ -161,6 +161,10 @@ process_request (const char *server_address, int server_port, int proto, | |||
161 | int | 161 | int |
162 | np_net_connect (const char *host_name, int port, int *sd, int proto) | 162 | np_net_connect (const char *host_name, int port, int *sd, int proto) |
163 | { | 163 | { |
164 | /* send back STATE_UNKOWN if there's an error | ||
165 | send back STATE_OK if we connect | ||
166 | send back STATE_CRITICAL if we can't connect. | ||
167 | Let upstream figure out what to send to the user. */ | ||
164 | struct addrinfo hints; | 168 | struct addrinfo hints; |
165 | struct addrinfo *r, *res; | 169 | struct addrinfo *r, *res; |
166 | struct sockaddr_un su; | 170 | struct sockaddr_un su; |
@@ -250,16 +254,14 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
250 | else if (was_refused) { | 254 | else if (was_refused) { |
251 | switch (econn_refuse_state) { /* a user-defined expected outcome */ | 255 | switch (econn_refuse_state) { /* a user-defined expected outcome */ |
252 | case STATE_OK: | 256 | case STATE_OK: |
253 | case STATE_WARNING: /* user wants WARN or OK on refusal */ | 257 | case STATE_WARNING: /* user wants WARN or OK on refusal, or... */ |
254 | return econn_refuse_state; | 258 | case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ |
255 | break; | ||
256 | case STATE_CRITICAL: /* user did not set econn_refuse_state */ | ||
257 | if (is_socket) | 259 | if (is_socket) |
258 | printf("connect to file socket %s: %s\n", host_name, strerror(errno)); | 260 | printf("connect to file socket %s: %s\n", host_name, strerror(errno)); |
259 | else | 261 | else |
260 | printf("connect to address %s and port %d: %s\n", | 262 | printf("connect to address %s and port %d: %s\n", |
261 | host_name, port, strerror(errno)); | 263 | host_name, port, strerror(errno)); |
262 | return econn_refuse_state; | 264 | return STATE_CRITICAL; |
263 | break; | 265 | break; |
264 | default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ | 266 | default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ |
265 | return STATE_UNKNOWN; | 267 | return STATE_UNKNOWN; |
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index 43b1a5a..4f9c793 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
@@ -195,7 +195,9 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
195 | # ifdef USE_OPENSSL | 195 | # ifdef USE_OPENSSL |
196 | X509 *certificate=NULL; | 196 | X509 *certificate=NULL; |
197 | X509_NAME *subj=NULL; | 197 | X509_NAME *subj=NULL; |
198 | char timestamp[50] = ""; | ||
198 | char cn[MAX_CN_LENGTH]= ""; | 199 | char cn[MAX_CN_LENGTH]= ""; |
200 | |||
199 | int cnlen =-1; | 201 | int cnlen =-1; |
200 | int status=STATE_UNKNOWN; | 202 | int status=STATE_UNKNOWN; |
201 | 203 | ||
@@ -204,7 +206,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
204 | struct tm stamp; | 206 | struct tm stamp; |
205 | float time_left; | 207 | float time_left; |
206 | int days_left; | 208 | int days_left; |
207 | char timestamp[50] = ""; | 209 | int time_remaining; |
208 | time_t tm_t; | 210 | time_t tm_t; |
209 | 211 | ||
210 | certificate=SSL_get_peer_certificate(s); | 212 | certificate=SSL_get_peer_certificate(s); |
@@ -258,7 +260,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
258 | (tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0'); | 260 | (tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0'); |
259 | stamp.tm_min = | 261 | stamp.tm_min = |
260 | (tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0'); | 262 | (tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0'); |
261 | stamp.tm_sec = 0; | 263 | stamp.tm_sec = |
264 | (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0'); | ||
262 | stamp.tm_isdst = -1; | 265 | stamp.tm_isdst = -1; |
263 | 266 | ||
264 | time_left = difftime(timegm(&stamp), time(NULL)); | 267 | time_left = difftime(timegm(&stamp), time(NULL)); |
@@ -269,21 +272,35 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
269 | if (days_left > 0 && days_left <= days_till_exp_warn) { | 272 | if (days_left > 0 && days_left <= days_till_exp_warn) { |
270 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); | 273 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); |
271 | if (days_left > days_till_exp_crit) | 274 | if (days_left > days_till_exp_crit) |
272 | return STATE_WARNING; | 275 | status = STATE_WARNING; |
273 | else | 276 | else |
274 | return STATE_CRITICAL; | 277 | status = STATE_CRITICAL; |
278 | } else if (days_left == 0 && time_left > 0) { | ||
279 | if (time_left >= 3600) | ||
280 | time_remaining = (int) time_left / 3600; | ||
281 | else | ||
282 | time_remaining = (int) time_left / 60; | ||
283 | |||
284 | printf (_("%s - Certificate '%s' expires in %u %s (%s)\n"), | ||
285 | (days_left>days_till_exp_crit) ? "WARNING" : "CRITICAL", cn, time_remaining, | ||
286 | time_left >= 3600 ? "hours" : "minutes", timestamp); | ||
287 | |||
288 | if ( days_left > days_till_exp_crit) | ||
289 | status = STATE_WARNING; | ||
290 | else | ||
291 | status = STATE_CRITICAL; | ||
275 | } else if (time_left < 0) { | 292 | } else if (time_left < 0) { |
276 | printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), cn, timestamp); | 293 | printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), cn, timestamp); |
277 | status=STATE_CRITICAL; | 294 | status=STATE_CRITICAL; |
278 | } else if (days_left == 0) { | 295 | } else if (days_left == 0) { |
279 | printf (_("%s - Certificate '%s' expires today (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, timestamp); | 296 | printf (_("%s - Certificate '%s' just expired (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, timestamp); |
280 | if (days_left > days_till_exp_crit) | 297 | if (days_left > days_till_exp_crit) |
281 | return STATE_WARNING; | 298 | status = STATE_WARNING; |
282 | else | 299 | else |
283 | return STATE_CRITICAL; | 300 | status = STATE_CRITICAL; |
284 | } else { | 301 | } else { |
285 | printf(_("OK - Certificate '%s' will expire on %s.\n"), cn, timestamp); | 302 | printf(_("OK - Certificate '%s' will expire on %s.\n"), cn, timestamp); |
286 | status=STATE_OK; | 303 | status = STATE_OK; |
287 | } | 304 | } |
288 | X509_free(certificate); | 305 | X509_free(certificate); |
289 | return status; | 306 | return status; |
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 2539a28..c2caec6 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -6,9 +6,10 @@ | |||
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test::More; | 8 | use Test::More; |
9 | use POSIX qw/mktime strftime/; | ||
9 | use NPTest; | 10 | use NPTest; |
10 | 11 | ||
11 | plan tests => 30; | 12 | plan tests => 42; |
12 | 13 | ||
13 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
14 | 15 | ||
@@ -34,6 +35,8 @@ my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", | |||
34 | "A host providing an index page containing the string 'monitoring'", | 35 | "A host providing an index page containing the string 'monitoring'", |
35 | "test.monitoring-plugins.org" ); | 36 | "test.monitoring-plugins.org" ); |
36 | 37 | ||
38 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; | ||
39 | |||
37 | 40 | ||
38 | $res = NPTest->testCmd( | 41 | $res = NPTest->testCmd( |
39 | "./check_http $host_tcp_http -wt 300 -ct 600" | 42 | "./check_http $host_tcp_http -wt 300 -ct 600" |
@@ -47,10 +50,10 @@ $res = NPTest->testCmd( | |||
47 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); | 50 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); |
48 | 51 | ||
49 | $res = NPTest->testCmd( | 52 | $res = NPTest->testCmd( |
50 | "./check_http $host_nonresponsive -wt 1 -ct 2" | 53 | "./check_http $host_nonresponsive -wt 1 -ct 2 -t 3" |
51 | ); | 54 | ); |
52 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); | 55 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); |
53 | cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 10 seconds", "Output OK"); | 56 | cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 3 seconds", "Output OK"); |
54 | 57 | ||
55 | $res = NPTest->testCmd( | 58 | $res = NPTest->testCmd( |
56 | "./check_http $hostname_invalid -wt 1 -ct 2" | 59 | "./check_http $hostname_invalid -wt 1 -ct 2" |
@@ -112,6 +115,40 @@ SKIP: { | |||
112 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); | 115 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); |
113 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); | 116 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); |
114 | 117 | ||
118 | # run some certificate checks with faketime | ||
119 | SKIP: { | ||
120 | skip "No faketime binary found", 12 if !$faketime; | ||
121 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com"); | ||
122 | like($res->output, qr/OK - Certificate 'www.verisign.com' will expire on/, "Catch cert output"); | ||
123 | is( $res->return_code, 0, "Catch cert output exit code" ); | ||
124 | my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)\./); | ||
125 | if(!defined $year) { | ||
126 | die("parsing date failed from: ".$res); | ||
127 | } | ||
128 | my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11}; | ||
129 | my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900); | ||
130 | my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts)); | ||
131 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_http -C 1 www.verisign.com"); | ||
132 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' just expired/, "Output on expire date"); | ||
133 | is( $res->return_code, 2, "Output on expire date" ); | ||
134 | |||
135 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./check_http -C 1 www.verisign.com"); | ||
136 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 0 minutes/, "cert expires in 1 second output"); | ||
137 | is( $res->return_code, 2, "cert expires in 1 second exit code" ); | ||
138 | |||
139 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./check_http -C 1 www.verisign.com"); | ||
140 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 minutes/, "cert expires in 2 minutes output"); | ||
141 | is( $res->return_code, 2, "cert expires in 2 minutes exit code" ); | ||
142 | |||
143 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./check_http -C 1 www.verisign.com"); | ||
144 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 hours/, "cert expires in 2 hours output"); | ||
145 | is( $res->return_code, 2, "cert expires in 2 hours exit code" ); | ||
146 | |||
147 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_http -C 1 www.verisign.com"); | ||
148 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expired on/, "Certificate expired output"); | ||
149 | is( $res->return_code, 2, "Certificate expired exit code" ); | ||
150 | }; | ||
151 | |||
115 | $res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" ); | 152 | $res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" ); |
116 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 153 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
117 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | 154 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); |
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index d93a0ec..e72d243 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -186,21 +186,21 @@ SKIP: { | |||
186 | 186 | ||
187 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); | 187 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); |
188 | is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); | 188 | is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); |
189 | is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:00 2019.', "output ok" ); | 189 | is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:28 2019.', "output ok" ); |
190 | 190 | ||
191 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); | 191 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); |
192 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); | 192 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); |
193 | like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" ); | 193 | like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019\)./', "output ok" ); |
194 | 194 | ||
195 | # Expired cert tests | 195 | # Expired cert tests |
196 | $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); | 196 | $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); |
197 | is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); | 197 | is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); |
198 | like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" ); | 198 | like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019\)./', "output ok" ); |
199 | 199 | ||
200 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); | 200 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); |
201 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); | 201 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); |
202 | is( $result->output, | 202 | is( $result->output, |
203 | 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:00 2009.', | 203 | 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009.', |
204 | "output ok" ); | 204 | "output ok" ); |
205 | 205 | ||
206 | } | 206 | } |
diff --git a/plugins/utils.c b/plugins/utils.c index 7f49e7b..a864e4a 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -144,8 +144,6 @@ usage5 (void) | |||
144 | void | 144 | void |
145 | print_revision (const char *command_name, const char *revision) | 145 | print_revision (const char *command_name, const char *revision) |
146 | { | 146 | { |
147 | char plugin_revision[STRLEN]; | ||
148 | |||
149 | printf ("%s v%s (%s %s)\n", | 147 | printf ("%s v%s (%s %s)\n", |
150 | command_name, revision, PACKAGE, VERSION); | 148 | command_name, revision, PACKAGE, VERSION); |
151 | } | 149 | } |