[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1834] nagiosplug/branches/dermoth_ntp_rework/ plugins/t/check_ntp.t
dermoth at users.sourceforge.net
dermoth at users.sourceforge.net
Mon Nov 26 08:53:30 CET 2007
Revision: 1834
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1834&view=rev
Author: dermoth
Date: 2007-11-25 23:53:30 -0800 (Sun, 25 Nov 2007)
Log Message:
-----------
More refined check, clearer messages
Modified Paths:
--------------
nagiosplug/branches/dermoth_ntp_rework/plugins/t/check_ntp.t
Modified: nagiosplug/branches/dermoth_ntp_rework/plugins/t/check_ntp.t
===================================================================
--- nagiosplug/branches/dermoth_ntp_rework/plugins/t/check_ntp.t 2007-11-23 22:06:28 UTC (rev 1833)
+++ nagiosplug/branches/dermoth_ntp_rework/plugins/t/check_ntp.t 2007-11-26 07:53:30 UTC (rev 1834)
@@ -12,7 +12,7 @@
my @PLUGINS1 = ('check_ntp', 'check_ntp_peer', 'check_ntp_time');
my @PLUGINS2 = ('check_ntp_peer');
-plan tests => (9 * scalar(@PLUGINS1)) + (6 * scalar(@PLUGINS2));
+plan tests => (12 * scalar(@PLUGINS1)) + (6 * scalar(@PLUGINS2));
my $res;
@@ -38,46 +38,52 @@
my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}/';
my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}/';
my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}/';
+my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/';
+my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/';
+
foreach my $plugin (@PLUGINS1) {
SKIP: {
skip "No NTP server defined", 1 unless $ntp_service;
$res = NPTest->testCmd(
"./$plugin -H $ntp_service -w 1000 -c 2000"
);
- cmp_ok( $res->return_code, '==', 0, "$plugin: Got good NTP result");
- like( $res->output, $ntp_okmatch1, "Output OK" );
+ cmp_ok( $res->return_code, '==', 0, "$plugin: Good NTP result (simple check)" );
+ like( $res->output, $ntp_okmatch1, "$plugin: Output match OK (simple check)" );
$res = NPTest->testCmd(
"./$plugin -H $ntp_service -w 1000: -c 2000"
);
- cmp_ok( $res->return_code, '==', 1, "$plugin: Got warning NTP result");
- like( $res->output, $ntp_warnmatch1, "Output WARNING" );
+ cmp_ok( $res->return_code, '==', 1, "$plugin: Warning NTP result (simple check)" );
+ like( $res->output, $ntp_warnmatch1, "$plugin: Output match WARNING (simple check)" );
$res = NPTest->testCmd(
"./$plugin -H $ntp_service -w 1000 -c 2000:"
);
- cmp_ok( $res->return_code, '==', 2, "$plugin: Got critical NTP result");
- like( $res->output, $ntp_critmatch1, "Output CRITICAL" );
+ cmp_ok( $res->return_code, '==', 2, "$plugin: Critical NTP result (simple check)" );
+ like( $res->output, $ntp_critmatch1, "$plugin: Output match CRITICAL (simple check)" );
}
SKIP: {
skip "No bad NTP server defined", 1 unless $no_ntp_service;
$res = NPTest->testCmd(
- "./$plugin -H $no_ntp_service"
+ "./$plugin -H $no_ntp_service -t 3"
);
- cmp_ok( $res->return_code, '==', 2, "$plugin: Got bad NTP result");
+ cmp_ok( $res->return_code, '==', 2, "$plugin: No NTP service" );
+ like( $res->output, $ntp_noresponse, "$plugin: Output match no NTP service" );
}
$res = NPTest->testCmd(
- "./$plugin -H $host_nonresponsive"
+ "./$plugin -H $host_nonresponsive -t 3"
);
- cmp_ok( $res->return_code, '==', 2, "$plugin: Got critical if server not responding");
+ cmp_ok( $res->return_code, '==', 2, "$plugin: Server not responding" );
+ like( $res->output, $ntp_noresponse, "$plugin: Output match non-responsive" );
$res = NPTest->testCmd(
"./$plugin -H $hostname_invalid"
);
- cmp_ok( $res->return_code, '==', 3, "$plugin: Got critical if server hostname invalid");
+ cmp_ok( $res->return_code, '==', 3, "$plugin: Invalid hostname/address" );
+ like( $res->output, $ntp_nosuchhost, "$plugin: Output match invalid hostname/address" );
}
@@ -87,19 +93,19 @@
$res = NPTest->testCmd(
"./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000"
);
- cmp_ok( $res->return_code, '==', 0, "$plugin: Got good NTP result");
- like( $res->output, $ntp_okmatch2, "Output OK" );
+ cmp_ok( $res->return_code, '==', 0, "$plugin: Good NTP result with jitter and stratum check" );
+ like( $res->output, $ntp_okmatch2, "$plugin: Output match OK with jitter and stratum" );
$res = NPTest->testCmd(
"./$plugin -H $ntp_service -w 1000 -c 2000 -W ~:-1 -C 21 -j 100000 -k 200000"
);
- cmp_ok( $res->return_code, '==', 1, "$plugin: Got warning NTP result");
- like( $res->output, $ntp_warnmatch2, "Output WARNING" );
+ cmp_ok( $res->return_code, '==', 1, "$plugin: Warning NTP result with jitter and stratum check" );
+ like( $res->output, $ntp_warnmatch2, "$plugin: Output match WARNING with jitter and stratum" );
$res = NPTest->testCmd(
"./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k ~:-1"
);
- cmp_ok( $res->return_code, '==', 2, "$plugin: Got critical NTP result");
- like( $res->output, $ntp_critmatch2, "Output CRITICAL" );
+ cmp_ok( $res->return_code, '==', 2, "$plugin: Critical NTP result with jitter and stratum check" );
+ like( $res->output, $ntp_critmatch2, "$plugin: Output match CRITICAL with jitter and stratum" );
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list