summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_http.c10
-rw-r--r--plugins/check_ssh.c2
-rw-r--r--plugins/t/check_http.t2
-rw-r--r--plugins/t/check_tcp.t18
-rw-r--r--plugins/utils.h11
5 files changed, 27 insertions, 16 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index d8b3f9c..92861d9 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -57,7 +57,7 @@ enum {
57 57
58#ifdef HAVE_SSL 58#ifdef HAVE_SSL
59int check_cert = FALSE; 59int check_cert = FALSE;
60int ssl_version; 60int ssl_version = 0;
61int days_till_exp_warn, days_till_exp_crit; 61int days_till_exp_warn, days_till_exp_crit;
62char *randbuff; 62char *randbuff;
63X509 *server_cert; 63X509 *server_cert;
@@ -257,7 +257,7 @@ process_arguments (int argc, char **argv)
257 } 257 }
258 258
259 while (1) { 259 while (1) {
260 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:N:E", longopts, &option); 260 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NE", longopts, &option);
261 if (c == -1 || c == EOF) 261 if (c == -1 || c == EOF)
262 break; 262 break;
263 263
@@ -339,10 +339,10 @@ process_arguments (int argc, char **argv)
339 case 'S': /* use SSL */ 339 case 'S': /* use SSL */
340#ifdef HAVE_SSL 340#ifdef HAVE_SSL
341 enable_ssl: 341 enable_ssl:
342 /* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple
343 parameters, like -S and -C combinations */
342 use_ssl = TRUE; 344 use_ssl = TRUE;
343 if (optarg == NULL || c != 'S') 345 if (c=='S' && optarg != NULL) {
344 ssl_version = 0;
345 else {
346 ssl_version = atoi(optarg); 346 ssl_version = atoi(optarg);
347 if (ssl_version < 1 || ssl_version > 3) 347 if (ssl_version < 1 || ssl_version > 3)
348 usage4 (_("Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 (SSLv3)")); 348 usage4 (_("Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 (SSLv3)"));
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index f4522e2..5c75d27 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -250,6 +250,7 @@ ssh_connect (char *haddr, int hport, char *remote_version)
250 printf 250 printf
251 (_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"), 251 (_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"),
252 ssh_server, ssh_proto, remote_version); 252 ssh_server, ssh_proto, remote_version);
253 recv (sd, output, BUFF_SZ, 0);
253 close(sd); 254 close(sd);
254 exit (STATE_WARNING); 255 exit (STATE_WARNING);
255 } 256 }
@@ -260,6 +261,7 @@ ssh_connect (char *haddr, int hport, char *remote_version)
260 (_("SSH OK - %s (protocol %s) | %s\n"), 261 (_("SSH OK - %s (protocol %s) | %s\n"),
261 ssh_server, ssh_proto, fperfdata("time", elapsed_time, "s", 262 ssh_server, ssh_proto, fperfdata("time", elapsed_time, "s",
262 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, (int)socket_timeout)); 263 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, (int)socket_timeout));
264 recv (sd, output, BUFF_SZ, 0);
263 close(sd); 265 close(sd);
264 exit (STATE_OK); 266 exit (STATE_OK);
265 } 267 }
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index a74220e..2539a28 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -82,7 +82,7 @@ SKIP: {
82 cmp_ok( $res->return_code, "==", 0, "And also when not found"); 82 cmp_ok( $res->return_code, "==", 0, "And also when not found");
83} 83}
84SKIP: { 84SKIP: {
85 skip "No internet access", 11 if $internet_access eq "no"; 85 skip "No internet access", 16 if $internet_access eq "no";
86 86
87 $res = NPTest->testCmd( 87 $res = NPTest->testCmd(
88 "./check_http --ssl www.verisign.com" 88 "./check_http --ssl www.verisign.com"
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t
index abb16ae..f996685 100644
--- a/plugins/t/check_tcp.t
+++ b/plugins/t/check_tcp.t
@@ -12,7 +12,6 @@ BEGIN {
12 use NPTest; 12 use NPTest;
13 $has_ipv6 = NPTest::has_ipv6(); 13 $has_ipv6 = NPTest::has_ipv6();
14 $tests = $has_ipv6 ? 14 : 11; 14 $tests = $has_ipv6 ? 14 : 11;
15 plan tests => $tests;
16} 15}
17 16
18 17
@@ -25,20 +24,29 @@ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRES
25my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", 24my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
26 "An invalid (not known to DNS) hostname" ); 25 "An invalid (not known to DNS) hostname" );
27 26
27my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
28 "Is this system directly connected to the internet?",
29 "yes");
30
28my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; 31my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/';
29 32
30my $failedExpect = '/^TCP WARNING\s-\sUnexpected response from host/socket on port [0-9]+/'; 33my $failedExpect = '/^TCP WARNING\s-\sUnexpected response from host/socket on port [0-9]+/';
31 34
32my $t; 35my $t;
33 36
37$tests = $tests - 4 if $internet_access eq "no";
38plan tests => $tests;
39
34$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput ); 40$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput );
35$t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test 41$t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test
36$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); 42$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 );
37$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); 43$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 );
38$t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 ); 44if($internet_access ne "no") {
39$t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 ); 45 $t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 );
40$t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); 46 $t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 );
41$t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); 47 $t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 );
48 $t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 );
49}
42 50
43# Need the \r\n to make it more standards compliant with web servers. Need the various quotes 51# Need the \r\n to make it more standards compliant with web servers. Need the various quotes
44# so that perl doesn't interpret the \r\n and is passed onto command line correctly 52# so that perl doesn't interpret the \r\n and is passed onto command line correctly
diff --git a/plugins/utils.h b/plugins/utils.h
index c9fd68d..1f37654 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -185,7 +185,8 @@ char *fperfdata (const char *,
185#ifdef NP_EXTRA_OPTS 185#ifdef NP_EXTRA_OPTS
186#define UT_EXTRA_OPTS _("\ 186#define UT_EXTRA_OPTS _("\
187 --extra-opts=[section][@file]\n\ 187 --extra-opts=[section][@file]\n\
188 Read options from an ini file. See http://monitoring-plugins.org/doc/extra-opts.html\n\ 188 Read options from an ini file. See\n\
189 https://www.monitoring-plugins.org/doc/extra-opts.html\n\
189 for usage and examples.\n") 190 for usage and examples.\n")
190#else 191#else
191#define UT_EXTRA_OPTS "" 192#define UT_EXTRA_OPTS ""
@@ -193,13 +194,13 @@ char *fperfdata (const char *,
193 194
194#define UT_THRESHOLDS_NOTES _("\ 195#define UT_THRESHOLDS_NOTES _("\
195 See:\n\ 196 See:\n\
196 http://monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n\ 197 https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n\
197 for THRESHOLD format and examples.\n") 198 for THRESHOLD format and examples.\n")
198 199
199#define UT_SUPPORT _("\n\ 200#define UT_SUPPORT _("\n\
200Send email to help@monitoring-plugins.org if you have questions\n\ 201Send email to help@monitoring-plugins.org if you have questions regarding\n\
201regarding use of this software. To submit patches or suggest improvements,\n\ 202use of this software. To submit patches or suggest improvements, send email\n\
202send email to devel@monitoring-plugins.org\n\n") 203to devel@monitoring-plugins.org\n\n")
203 204
204#define UT_NOWARRANTY _("\n\ 205#define UT_NOWARRANTY _("\n\
205The monitoring plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n\ 206The monitoring plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n\