[Nagiosplug-checkins] nagiosplug/plugins/t check_disk.t,1.15,1.16

Ton Voon tonvoon at users.sourceforge.net
Mon Jan 8 12:05:57 CET 2007


Update of /cvsroot/nagiosplug/nagiosplug/plugins/t
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25569/plugins/t

Modified Files:
	check_disk.t 
Log Message:
Added notes about check_disk perf data fix. Added test to check perf data is 
same when mount points reversed


Index: check_disk.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_disk.t,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- check_disk.t	20 Dec 2006 19:25:59 -0000	1.15
+++ check_disk.t	8 Jan 2007 11:05:55 -0000	1.16
@@ -24,7 +24,7 @@
 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 @@
 $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 @@
 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 @@
 
 
 
-# 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" 
+	);
+ at _ = 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 @@
 	"./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"





More information about the Commits mailing list