From 24242f6ab75adb2de617921e79fe6bece4b75612 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Mon, 25 Jun 2012 12:32:01 +0200 Subject: check_http: added test for warning thresholds fixed typo in sslutils --- plugins/sslutils.c | 4 ++-- plugins/t/check_http.t | 6 +++++- plugins/t/check_tcp.t | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/sslutils.c b/plugins/sslutils.c index fe31b562..a1ce560d 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){ stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min); if (days_left > 0 && days_left <= days_till_exp_warn) { - printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"CRITICAL":"WARNING", cn, days_left, timestamp); + printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); if (days_left > days_till_exp_crit) return STATE_WARNING; else @@ -212,7 +212,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), cn, timestamp); status=STATE_CRITICAL; } else if (days_left == 0) { - printf (_("%s - Certificate '%s' expires today (%s).\n"), (days_left>days_till_exp_crit)?"CRITICAL":"WARNING", cn, timestamp); + printf (_("%s - Certificate '%s' expires today (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, timestamp); if (days_left > days_till_exp_crit) return STATE_WARNING; else diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 55a5a530..0a25c775 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t @@ -8,7 +8,7 @@ use strict; use Test::More; use NPTest; -plan tests => 26; +plan tests => 28; my $successOutput = '/OK.*HTTP.*second/'; @@ -105,6 +105,10 @@ SKIP: { like ( $res->output, "/Certificate 'www.verisign.com' will expire on/", "Output OK" ); my $saved_cert_output = $res->output; + $res = NPTest->testCmd( "./check_http -C 8000,1 --ssl www.verisign.com" ); + cmp_ok( $res->return_code, '==', 1, "Checking certificate for www.verisign.com"); + like ( $res->output, qr/WARNING - Certificate 'www.verisign.com' expires in \d+ day/, "Output Warning" ); + $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); is( $res->return_code, 0, "Old syntax for cert checking okay" ); 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 fd2b5dd9..75c1e5fb 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 $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test $t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); $t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); +$t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 ); +$t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 0 ); +$t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); +$t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); # Need the \r\n to make it more standards compliant with web servers. Need the various quotes # so that perl doesn't interpret the \r\n and is passed onto command line correctly -- cgit v1.2.3-74-g34f1