diff options
Diffstat (limited to 'plugins/t/check_disk.t')
-rw-r--r-- | plugins/t/check_disk.t | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index bf8dd362..9eb77ce4 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -44,7 +44,7 @@ my @perf_data = sort(split(/ /, $result->perf_output)); | |||
44 | # Calculate avg_free free on mountpoint1 and mountpoint2 | 44 | # Calculate avg_free free on mountpoint1 and mountpoint2 |
45 | # because if you check in the middle, you should get different errors | 45 | # because if you check in the middle, you should get different errors |
46 | $_ = $result->output; | 46 | $_ = $result->output; |
47 | my ($free_on_mp1, $free_on_mp2) = (m/\((\d+)%.*\((\d+)%/); | 47 | my ($free_on_mp1, $free_on_mp2) = (m/\((\d+\.\d+)%.*\((\d+\.\d+)%/); |
48 | die "Cannot parse output: $_" unless ($free_on_mp1 && $free_on_mp2); | 48 | die "Cannot parse output: $_" unless ($free_on_mp1 && $free_on_mp2); |
49 | my $avg_free = ceil(($free_on_mp1+$free_on_mp2)/2); | 49 | my $avg_free = ceil(($free_on_mp1+$free_on_mp2)/2); |
50 | my ($more_free, $less_free); | 50 | my ($more_free, $less_free); |
@@ -119,8 +119,12 @@ like ( $result->only_output, qr/$more_free/, "Have disk name in text"); | |||
119 | 119 | ||
120 | $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" ); | 120 | $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" ); |
121 | cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free"); | 121 | cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free"); |
122 | |||
122 | $_ = $result->output; | 123 | $_ = $result->output; |
124 | |||
123 | my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+)MiB .* (\d+)MiB /g); | 125 | my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+)MiB .* (\d+)MiB /g); |
126 | die "Cannot parse output: $_" unless ($free_mb_on_mp1 && $free_mb_on_mp2); | ||
127 | |||
124 | my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2; | 128 | my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2; |
125 | 129 | ||
126 | 130 | ||
@@ -311,8 +315,8 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -C -w 0% -c 0% -p $mountpoi | |||
311 | like( $result->output, '/;.*;\|/', "-C selects partitions if -p is not given"); | 315 | like( $result->output, '/;.*;\|/', "-C selects partitions if -p is not given"); |
312 | 316 | ||
313 | # grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit | 317 | # grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit |
314 | $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" ); | 318 | $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" ); |
315 | cmp_ok( $result->return_code, '==', 2, "grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit"); | 319 | 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); |
316 | 320 | ||
317 | # grouping: exit warning if the sum of free megs on mp1+mp2 is between -w and -c | 321 | # grouping: exit warning if the sum of free megs on mp1+mp2 is between -w and -c |
318 | $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 | $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" ); |