Imported Upstream version 1.4.11
This commit is contained in:
parent
cff68b4c0a
commit
1d1585cd09
72 changed files with 16170 additions and 13657 deletions
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# Load Average Tests via check_load
|
||||
#
|
||||
# $Id: check_load.t 1700 2007-04-25 22:10:13Z tonvoon $
|
||||
# $Id: check_load.t 1851 2007-12-10 00:19:27Z psychotrahe $
|
||||
#
|
||||
|
||||
use strict;
|
||||
|
@ -11,10 +11,11 @@ use NPTest;
|
|||
|
||||
my $res;
|
||||
|
||||
my $successOutput = '/^OK - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/';
|
||||
my $failureOutput = '/^CRITICAL - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/';
|
||||
my $loadValue = "[0-9]+\.?[0-9]+";
|
||||
my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/";
|
||||
my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/";
|
||||
|
||||
plan tests => 6;
|
||||
plan tests => 11;
|
||||
|
||||
$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
|
||||
cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
|
||||
|
@ -28,3 +29,9 @@ $res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
|
|||
cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
|
||||
like( $res->output, $failureOutput, "Output OK");
|
||||
|
||||
$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
|
||||
cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
|
||||
like( $res->output, $successOutput, "Output OK");
|
||||
like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
|
||||
like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
|
||||
like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
#
|
||||
# Testing NTP
|
||||
#
|
||||
# $Id: check_ntp.t 1468 2006-08-14 08:42:23Z tonvoon $
|
||||
# $Id: check_ntp.t 1865 2007-12-11 13:54:23Z dermoth $
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
plan tests => 4;
|
||||
my @PLUGINS1 = ('check_ntp', 'check_ntp_peer', 'check_ntp_time');
|
||||
my @PLUGINS2 = ('check_ntp_peer');
|
||||
|
||||
plan tests => (12 * scalar(@PLUGINS1)) + (6 * scalar(@PLUGINS2));
|
||||
|
||||
my $res;
|
||||
|
||||
|
@ -25,33 +28,84 @@ my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
|
|||
"The hostname of system not responsive to network requests",
|
||||
"10.0.0.1" );
|
||||
|
||||
my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
|
||||
my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
|
||||
"An invalid (not known to DNS) hostname",
|
||||
"nosuchhost");
|
||||
|
||||
SKIP: {
|
||||
skip "No NTP server defined", 1 unless $ntp_service;
|
||||
my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
|
||||
my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
|
||||
my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
|
||||
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: 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: 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: 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 -t 3"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 2, "$plugin: No NTP service" );
|
||||
like( $res->output, $ntp_noresponse, "$plugin: Output match no NTP service" );
|
||||
}
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ntp -H $ntp_service"
|
||||
"./$plugin -H $host_nonresponsive -t 3"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 0, "Got good NTP result");
|
||||
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: Invalid hostname/address" );
|
||||
like( $res->output, $ntp_nosuchhost, "$plugin: Output match invalid hostname/address" );
|
||||
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "No bad NTP server defined", 1 unless $no_ntp_service;
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ntp -H $no_ntp_service"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 2, "Got bad NTP result");
|
||||
foreach my $plugin (@PLUGINS2) {
|
||||
SKIP: {
|
||||
skip "No NTP server defined", 1 unless $ntp_service;
|
||||
$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: 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: 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: Critical NTP result with jitter and stratum check" );
|
||||
like( $res->output, $ntp_critmatch2, "$plugin: Output match CRITICAL with jitter and stratum" );
|
||||
}
|
||||
}
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ntp -H $host_nonresponsive"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 2, "Got critical if server not responding");
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ntp -H $hostname_invalid"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 3, "Got critical if server hostname invalid");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue