diff options
author | Sven Nierlein <sven@nierlein.de> | 2012-06-25 10:32:01 (GMT) |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2012-06-25 10:53:47 (GMT) |
commit | 24242f6ab75adb2de617921e79fe6bece4b75612 (patch) | |
tree | a2eedd5f2c21c8c152f855d20867b208bfa38ebc | |
parent | eb2615a0bae70dc5ee5020b9d96d1ae7c95d1728 (diff) | |
download | monitoring-plugins-24242f6ab75adb2de617921e79fe6bece4b75612.tar.gz |
check_http: added test for warning thresholds
fixed typo in sslutils
-rw-r--r-- | plugins/sslutils.c | 4 | ||||
-rw-r--r-- | plugins/t/check_http.t | 6 | ||||
-rw-r--r-- | plugins/t/check_tcp.t | 4 |
3 files changed, 11 insertions, 3 deletions
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index fe31b56..a1ce560 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
@@ -203,7 +203,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
203 | stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min); | 203 | stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min); |
204 | 204 | ||
205 | if (days_left > 0 && days_left <= days_till_exp_warn) { | 205 | if (days_left > 0 && days_left <= days_till_exp_warn) { |
206 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"CRITICAL":"WARNING", cn, days_left, timestamp); | 206 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); |
207 | if (days_left > days_till_exp_crit) | 207 | if (days_left > days_till_exp_crit) |
208 | return STATE_WARNING; | 208 | return STATE_WARNING; |
209 | else | 209 | else |
@@ -212,7 +212,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
212 | printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), cn, timestamp); | 212 | printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), cn, timestamp); |
213 | status=STATE_CRITICAL; | 213 | status=STATE_CRITICAL; |
214 | } else if (days_left == 0) { | 214 | } else if (days_left == 0) { |
215 | printf (_("%s - Certificate '%s' expires today (%s).\n"), (days_left>days_till_exp_crit)?"CRITICAL":"WARNING", cn, timestamp); | 215 | printf (_("%s - Certificate '%s' expires today (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, timestamp); |
216 | if (days_left > days_till_exp_crit) | 216 | if (days_left > days_till_exp_crit) |
217 | return STATE_WARNING; | 217 | return STATE_WARNING; |
218 | else | 218 | else |
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 55a5a53..0a25c77 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -8,7 +8,7 @@ use strict; | |||
8 | use Test::More; | 8 | use Test::More; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | plan tests => 26; | 11 | plan tests => 28; |
12 | 12 | ||
13 | my $successOutput = '/OK.*HTTP.*second/'; | 13 | my $successOutput = '/OK.*HTTP.*second/'; |
14 | 14 | ||
@@ -105,6 +105,10 @@ SKIP: { | |||
105 | like ( $res->output, "/Certificate 'www.verisign.com' will expire on/", "Output OK" ); | 105 | like ( $res->output, "/Certificate 'www.verisign.com' will expire on/", "Output OK" ); |
106 | my $saved_cert_output = $res->output; | 106 | my $saved_cert_output = $res->output; |
107 | 107 | ||
108 | $res = NPTest->testCmd( "./check_http -C 8000,1 --ssl www.verisign.com" ); | ||
109 | cmp_ok( $res->return_code, '==', 1, "Checking certificate for www.verisign.com"); | ||
110 | like ( $res->output, qr/WARNING - Certificate 'www.verisign.com' expires in \d+ day/, "Output Warning" ); | ||
111 | |||
108 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); | 112 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); |
109 | is( $res->return_code, 0, "Old syntax for cert checking okay" ); | 113 | is( $res->return_code, 0, "Old syntax for cert checking okay" ); |
110 | is( $res->output, $saved_cert_output, "Same output as new syntax" ); | 114 | is( $res->output, $saved_cert_output, "Same output as new syntax" ); |
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t index fd2b5dd..75c1e5f 100644 --- a/plugins/t/check_tcp.t +++ b/plugins/t/check_tcp.t | |||
@@ -30,6 +30,10 @@ $t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0 | |||
30 | $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test | 30 | $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test |
31 | $t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); | 31 | $t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); |
32 | $t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); | 32 | $t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); |
33 | $t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 ); | ||
34 | $t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 0 ); | ||
35 | $t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); | ||
36 | $t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); | ||
33 | 37 | ||
34 | # Need the \r\n to make it more standards compliant with web servers. Need the various quotes | 38 | # Need the \r\n to make it more standards compliant with web servers. Need the various quotes |
35 | # so that perl doesn't interpret the \r\n and is passed onto command line correctly | 39 | # so that perl doesn't interpret the \r\n and is passed onto command line correctly |