From 4734e245f0675411da64b5627b58bef10d9f1129 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Mon, 8 Jan 2007 11:05:55 +0000 Subject: Added notes about check_disk perf data fix. Added test to check perf data is same when mount points reversed git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1565 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/CHANGES b/CHANGES index 3f5c0a6..d1abed0 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ This file documents the major additions and syntax changes between releases. Fixed Solaris problems with check_swap (tested on Solaris 9) Fixed check_swap for HP/UX where swapinfo command was incorrect Fixed check_disk inode threshold checks, regressed at r1.4.4. + Fixed crit/warn for check_disk perf data 1.4.5 Fixed bug in perl's is_hostname routine diff --git a/THANKS.in b/THANKS.in index 031cc4a..01fc458 100644 --- a/THANKS.in +++ b/THANKS.in @@ -204,3 +204,4 @@ Pawel Malachowski Duncan Ferguson Dick van den Burg Matthias Eble +Sebastian Schubert diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index dd4fcee..50d2e6d 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t @@ -24,7 +24,7 @@ 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 => 56; + plan tests => 57; } $result = NPTest->testCmd( @@ -36,6 +36,12 @@ $_ = $result->output; $c++ while /\(/g; # counts number of "(" - should be two cmp_ok( $c, '==', 2, "Got two mountpoints in output"); + +# Get perf data +# Should use Nagios::Plugin +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; @@ -63,7 +69,7 @@ my ($more_inode_free, $less_inode_free); if ($free_inode_on_mp1 > $free_inode_on_mp2) { $more_inode_free = $mountpoint_valid; $less_inode_free = $mountpoint2_valid; -} elsif ($free_on_mp1 < $free_on_mp2) { +} elsif ($free_inode_on_mp1 < $free_inode_on_mp2) { $more_inode_free = $mountpoint2_valid; $less_inode_free = $mountpoint_valid; } else { @@ -72,8 +78,15 @@ if ($free_inode_on_mp1 > $free_inode_on_mp2) { -# Basic filesystem checks for sizes +# 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" + ); +@_ = sort(split(/ /, $result->perf_output)); +is_deeply( \@perf_data, \@_, "perf data for both filesystems same when reversed"); + +# Basic filesystem checks for sizes $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" ); cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free"); like ( $result->output, $successOutput, "OK output" ); @@ -116,9 +129,11 @@ $result = NPTest->testCmd( "./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"); -like( $result->output, qr/$less_free/, "Found problem $less_free"); -unlike( $result->only_output, qr/$more_free/, "Has ignored $more_free as not a problem"); -like( $result->perf_output, qr/$more_free/, "But $more_free is still in perf data"); + +# Need spaces around filesystem name in case less_free and more_free are nested +like( $result->output, qr/ $less_free /, "Found problem $less_free"); +unlike( $result->only_output, qr/ $more_free /, "Has ignored $more_free as not a problem"); +like( $result->perf_output, qr/ $more_free=/, "But $more_free is still in perf data"); $result = NPTest->testCmd( "./check_disk -w $avg_free% -c 0% -p $more_free" -- cgit v0.10-9-g596f