New upstream version 2.4.0
This commit is contained in:
parent
d5a5faa95b
commit
600e193ca4
102 changed files with 16219 additions and 31778 deletions
|
@ -205,9 +205,9 @@ SKIP: {
|
|||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" );
|
||||
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" );
|
||||
is( $res->return_code, 0, "Redirection based on location is okay");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
|
||||
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" );
|
||||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth
|
|||
if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
|
||||
plan skip_all => "Need 2 mountpoints to test";
|
||||
} else {
|
||||
plan tests => 88;
|
||||
plan tests => 94;
|
||||
}
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 1% -c 1% -p $mountpoint_valid -w 1% -c 1% -p $mountpoint2_valid"
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 1% -c 1% -p $mountpoint_valid -w 1% -c 1% -p $mountpoint2_valid"
|
||||
);
|
||||
cmp_ok( $result->return_code, "==", 0, "Checking two mountpoints (must have at least 1% free in space and inodes)");
|
||||
my $c = 0;
|
||||
|
@ -44,7 +44,7 @@ my @perf_data = sort(split(/ /, $result->perf_output));
|
|||
# Calculate avg_free free on mountpoint1 and mountpoint2
|
||||
# because if you check in the middle, you should get different errors
|
||||
$_ = $result->output;
|
||||
my ($free_on_mp1, $free_on_mp2) = (m/\((\d+)%.*\((\d+)%/);
|
||||
my ($free_on_mp1, $free_on_mp2) = (m/\((\d+\.\d+)%.*\((\d+\.\d+)%/);
|
||||
die "Cannot parse output: $_" unless ($free_on_mp1 && $free_on_mp2);
|
||||
my $avg_free = ceil(($free_on_mp1+$free_on_mp2)/2);
|
||||
my ($more_free, $less_free);
|
||||
|
@ -103,8 +103,8 @@ is ($crit_percth_data, int((1-10/100)*$total_percth_data), "Wrong critical in pe
|
|||
|
||||
|
||||
# Check when order of mount points are reversed, that perf data remains same
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 1% -c 1% -p $mountpoint2_valid -w 1% -c 1% -p $mountpoint_valid"
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 1% -c 1% -p $mountpoint2_valid -w 1% -c 1% -p $mountpoint_valid"
|
||||
);
|
||||
@_ = sort(split(/ /, $result->perf_output));
|
||||
is_deeply( \@perf_data, \@_, "perf data for both filesystems same when reversed");
|
||||
|
@ -119,8 +119,12 @@ like ( $result->only_output, qr/$more_free/, "Have disk name in text");
|
|||
|
||||
$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" );
|
||||
cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free");
|
||||
|
||||
$_ = $result->output;
|
||||
|
||||
my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+)MiB .* (\d+)MiB /g);
|
||||
die "Cannot parse output: $_" unless ($free_mb_on_mp1 && $free_mb_on_mp2);
|
||||
|
||||
my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2;
|
||||
|
||||
|
||||
|
@ -134,8 +138,8 @@ cmp_ok( $result->return_code, '==', 0, "Old syntax okay" );
|
|||
$result = NPTest->testCmd( "./check_disk -w 1% -c 1% -p $more_free" );
|
||||
cmp_ok( $result->return_code, "==", 0, "At least 1% free" );
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 1% -c 1% -p $more_free -w 100% -c 100% -p $less_free"
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w 1% -c 1% -p $more_free -w 100% -c 100% -p $less_free"
|
||||
);
|
||||
cmp_ok( $result->return_code, "==", 2, "Get critical on less_free mountpoint $less_free" );
|
||||
like( $result->output, $failureOutput, "Right output" );
|
||||
|
@ -151,14 +155,14 @@ $result = NPTest->testCmd(
|
|||
);
|
||||
cmp_ok( $result->return_code, '==', 0, "Get ok on more_free mountpoint, when checking avg_free");
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
|
||||
);
|
||||
cmp_ok( $result->return_code, "==", 1, "Combining above two tests, get warning");
|
||||
my $all_disks = $result->output;
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
|
||||
"./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
|
||||
);
|
||||
isnt( $result->output, $all_disks, "-e gives different output");
|
||||
|
||||
|
@ -240,7 +244,7 @@ TODO: {
|
|||
cmp_ok( $result->return_code, '==', 3, "Invalid command line options" );
|
||||
}
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
$result = NPTest->testCmd(
|
||||
"./check_disk -p $mountpoint_valid -w 10% -c 15%"
|
||||
);
|
||||
cmp_ok( $result->return_code, "==", 3, "Invalid options: -p must come after thresholds" );
|
||||
|
@ -311,8 +315,8 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -C -w 0% -c 0% -p $mountpoi
|
|||
like( $result->output, '/;.*;\|/', "-C selects partitions if -p is not given");
|
||||
|
||||
# grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit
|
||||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all + 1) ."-g group -p $mountpoint_valid -p $mountpoint2_valid" );
|
||||
cmp_ok( $result->return_code, '==', 2, "grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit");
|
||||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all + 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
|
||||
cmp_ok( $result->return_code, '==', 2, "grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit\nInstead received: " . $result->output);
|
||||
|
||||
# grouping: exit warning if the sum of free megs on mp1+mp2 is between -w and -c
|
||||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all - 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
|
||||
|
@ -322,7 +326,7 @@ cmp_ok( $result->return_code, '==', 1, "grouping: exit warning if the sum of fre
|
|||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
|
||||
cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free megs on mp1+mp2 is more than warn/crit");
|
||||
|
||||
# grouping: exit unknown if group name is given after -p
|
||||
# grouping: exit unknown if group name is given after -p
|
||||
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" );
|
||||
cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname");
|
||||
|
||||
|
@ -355,17 +359,17 @@ like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mo
|
|||
# ignore-missing: exit okay, when fs is not accessible
|
||||
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p /bob");
|
||||
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for not existing filesystem /bob");
|
||||
like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /bob;.*$/', 'Output OK');
|
||||
like( $result->output, '/^DISK OK - No disks were found for provided parameters - ignored paths: /bob;.*$/', 'Output OK');
|
||||
|
||||
# ignore-missing: exit okay, when regex does not match
|
||||
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r /bob");
|
||||
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
|
||||
like( $result->output, '/^DISK OK - No disks were found for provided parameters;.*$/', 'Output OK');
|
||||
like( $result->output, '/^DISK OK - No disks were found for provided parameters.*$/', 'Output OK');
|
||||
|
||||
# ignore-missing: exit okay, when fs with exact match (-E) is not found
|
||||
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -E -p /etc");
|
||||
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay when exact match does not find fs");
|
||||
like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /etc;.*$/', 'Output OK');
|
||||
like( $result->output, '/^DISK OK - No disks were found for provided parameters - ignored paths: /etc;.*$/', 'Output OK');
|
||||
|
||||
# ignore-missing: exit okay, when checking one existing fs and one non-existing fs (regex)
|
||||
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r '/bob' -r '^/\$'");
|
||||
|
@ -375,4 +379,19 @@ like( $result->output, '/^DISK OK - free space: \/ .*$/', 'Output OK');
|
|||
# ignore-missing: exit okay, when checking one existing fs and one non-existing fs (path)
|
||||
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p '/bob' -p '/'");
|
||||
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
|
||||
like( $result->output, '/^DISK OK - free space: / .*; - ignored paths: /bob;.*$/', 'Output OK');
|
||||
like( $result->output, '/^DISK OK - free space: / .*; - ignored paths: /bob;.*$/', 'Output OK');
|
||||
|
||||
# ignore-missing: exit okay, when checking one non-existing fs (path) and one ignored
|
||||
$result = NPTest->testCmd( "./check_disk -n -w 0% -c 0% -r /dummy -i /dummy2");
|
||||
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
|
||||
like( $result->output, '/^DISK OK - No disks were found for provided parameters\|$/', 'Output OK');
|
||||
|
||||
# ignore-missing: exit okay, when regex match does not find anything
|
||||
$result = NPTest->testCmd( "./check_disk -n -e -l -w 10% -c 5% -W 10% -K 5% -r /dummy");
|
||||
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
|
||||
like( $result->output, '/^DISK OK\|$/', 'Output OK');
|
||||
|
||||
# ignore-missing: exit okay, when regex match does not find anything
|
||||
$result = NPTest->testCmd( "./check_disk -n -l -w 10% -c 5% -W 10% -K 5% -r /dummy");
|
||||
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
|
||||
like( $result->output, '/^DISK OK - No disks were found for provided parameters\|$/', 'Output OK');
|
||||
|
|
|
@ -166,10 +166,10 @@ SKIP: {
|
|||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
|
||||
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" );
|
||||
is( $res->return_code, 0, "Redirection based on location is okay");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
|
||||
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" );
|
||||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
}
|
||||
|
||||
|
|
|
@ -8,34 +8,116 @@ use strict;
|
|||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
my $res;
|
||||
|
||||
# Required parameters
|
||||
my $ssh_host = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost");
|
||||
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", "An invalid (not known to DNS) hostname", "nosuchhost" );
|
||||
my $ssh_host = getTestParameter("NP_SSH_HOST",
|
||||
"A host providing SSH service",
|
||||
"localhost");
|
||||
|
||||
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",
|
||||
"An invalid (not known to DNS) hostname",
|
||||
"nosuchhost" );
|
||||
|
||||
|
||||
plan skip_all => "SSH_HOST must be defined" unless $ssh_host;
|
||||
plan tests => 6;
|
||||
plan tests => 14 + 6;
|
||||
|
||||
SKIP: {
|
||||
skip "SSH_HOST must be defined", 6 unless $ssh_host;
|
||||
my $result = NPTest->testCmd(
|
||||
"./check_ssh -H $ssh_host"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
|
||||
|
||||
|
||||
my $result = NPTest->testCmd(
|
||||
"./check_ssh -H $ssh_host"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
|
||||
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_ssh -H $host_nonresponsive -t 2"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
|
||||
$result = NPTest->testCmd(
|
||||
"./check_ssh -H $host_nonresponsive -t 2"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
|
||||
|
||||
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_ssh -H $hostname_invalid -t 2"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");
|
||||
$result = NPTest->testCmd(
|
||||
"./check_ssh -H $hostname_invalid -t 2"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");
|
||||
|
||||
|
||||
}
|
||||
SKIP: {
|
||||
|
||||
skip "No netcat available", 14 unless (system("which nc > /dev/null") == 0);
|
||||
|
||||
# netcat on linux (on debian) will just keep the socket open if not advised otherwise
|
||||
# therefore we add -q to close it after two seconds after receiving the EOF from input
|
||||
my $nc_flags = "-l 5003 -N";
|
||||
#A valid protocol version control string has the form
|
||||
# SSH-protoversion-softwareversion SP comments CR LF
|
||||
#
|
||||
# where `comments` is optional, protoversion is the SSH protocol version and
|
||||
# softwareversion is an arbitrary string representing the server software version
|
||||
open(NC, "echo 'SSH-2.0-nagiosplug.ssh.0.1' | nc ${nc_flags}|");
|
||||
sleep 0.1;
|
||||
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Got SSH protocol version control string");
|
||||
like( $res->output, '/^SSH OK - nagiosplug.ssh.0.1 \(protocol 2.0\)/', "Output OK");
|
||||
close NC;
|
||||
|
||||
open(NC, "echo 'SSH-2.0-3.2.9.1' | nc ${nc_flags}|");
|
||||
sleep 0.1;
|
||||
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
||||
cmp_ok( $res->return_code, "==", 0, "Got SSH protocol version control string with non-alpha softwareversion string");
|
||||
like( $res->output, '/^SSH OK - 3.2.9.1 \(protocol 2.0\)/', "Output OK for non-alpha softwareversion string");
|
||||
close NC;
|
||||
|
||||
open(NC, "echo 'SSH-2.0-nagiosplug.ssh.0.1 this is a comment' | nc ${nc_flags} |");
|
||||
sleep 0.1;
|
||||
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003 -r nagiosplug.ssh.0.1" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Got SSH protocol version control string, and parsed comment appropriately");
|
||||
like( $res->output, '/^SSH OK - nagiosplug.ssh.0.1 \(protocol 2.0\)/', "Output OK");
|
||||
close NC;
|
||||
|
||||
open(NC, "echo 'SSH-' | nc ${nc_flags}|");
|
||||
sleep 0.1;
|
||||
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
||||
cmp_ok( $res->return_code, '==', 2, "Got invalid SSH protocol version control string");
|
||||
like( $res->output, '/^SSH CRITICAL/', "Output OK");
|
||||
close NC;
|
||||
|
||||
open(NC, "echo '' | nc ${nc_flags}|");
|
||||
sleep 0.1;
|
||||
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
||||
cmp_ok( $res->return_code, '==', 2, "No version control string received");
|
||||
like( $res->output, '/^SSH CRITICAL - No version control string received/', "Output OK");
|
||||
close NC;
|
||||
|
||||
open(NC, "echo 'Not a version control string' | nc ${nc_flags}|");
|
||||
sleep 0.1;
|
||||
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
||||
cmp_ok( $res->return_code, '==', 2, "No version control string received");
|
||||
like( $res->output, '/^SSH CRITICAL - No version control string received/', "Output OK");
|
||||
close NC;
|
||||
|
||||
|
||||
#RFC 4253 permits servers to send any number of data lines prior to sending the protocol version control string
|
||||
open(NC, "{ echo 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; sleep 0.5;
|
||||
echo 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'; sleep 0.5;
|
||||
echo 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'; sleep 0.2;
|
||||
echo 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD'; sleep 0.3;
|
||||
printf 'EEEEEEEEEEEEEEEEEE'; sleep 0.2;
|
||||
printf 'EEEEEEEEEEEEEEEEEE\n'; sleep 0.2;
|
||||
echo 'Some\nPrepended\nData\nLines\n'; sleep 0.2;
|
||||
echo 'SSH-2.0-nagiosplug.ssh.0.2';} | nc ${nc_flags}|");
|
||||
sleep 0.1;
|
||||
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Got delayed SSH protocol version control string");
|
||||
like( $res->output, '/^SSH OK - nagiosplug.ssh.0.2 \(protocol 2.0\)/', "Output OK");
|
||||
close NC;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#
|
||||
|
||||
use strict;
|
||||
use Test::More tests => 8;
|
||||
use Test::More tests => 14;
|
||||
use NPTest;
|
||||
|
||||
my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
|
||||
|
@ -14,6 +14,10 @@ my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)
|
|||
|
||||
my $result;
|
||||
|
||||
$result = NPTest->testCmd( "./check_swap" ); # Always OK
|
||||
cmp_ok( $result->return_code, "==", 0, "Always OK" );
|
||||
like( $result->output, $successOutput, "Right output" );
|
||||
|
||||
$result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" ); # 1 MB free
|
||||
cmp_ok( $result->return_code, "==", 0, "At least 1MB free" );
|
||||
like( $result->output, $successOutput, "Right output" );
|
||||
|
@ -29,3 +33,11 @@ like( $result->output, $failureOutput, "Right output" );
|
|||
$result = NPTest->testCmd( "./check_swap -w 100% -c 1%" ); # 100% (always warn)
|
||||
cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
|
||||
like( $result->output, $warnOutput, "Right output" );
|
||||
|
||||
$result = NPTest->testCmd( "./check_swap -w 100%" ); # 100% (single threshold, always warn)
|
||||
cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
|
||||
like( $result->output, $warnOutput, "Right output" );
|
||||
|
||||
$result = NPTest->testCmd( "./check_swap -c 100%" ); # 100% (single threshold, always critical)
|
||||
cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' );
|
||||
like( $result->output, $failureOutput, "Right output" );
|
||||
|
|
|
@ -13,10 +13,11 @@ use Test;
|
|||
use NPTest;
|
||||
|
||||
use vars qw($tests);
|
||||
BEGIN {$tests = 8; plan tests => $tests}
|
||||
BEGIN {$tests = 12; plan tests => $tests}
|
||||
|
||||
my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/';
|
||||
my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/';
|
||||
my $wrongOptionOutput = '/Usage:/';
|
||||
|
||||
my $t;
|
||||
|
||||
|
@ -24,6 +25,8 @@ $t += checkCmd( "./check_users 1000 1000", 0, $successOutput );
|
|||
$t += checkCmd( "./check_users 0 0", 2, $failureOutput );
|
||||
$t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput );
|
||||
$t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput );
|
||||
$t += checkCmd( "./check_users -w 0:1000", 3, $wrongOptionOutput);
|
||||
$t += checkCmd( "./check_users", 3, $wrongOptionOutput);
|
||||
|
||||
exit(0) if defined($Test::Harness::VERSION);
|
||||
exit($tests - $t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue