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

Ton Voon tonvoon at users.sourceforge.net
Wed Dec 20 20:26:01 CET 2006


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

Modified Files:
	check_disk.t 
Log Message:
Fixed inode thresholds, regressed from previous release


Index: check_disk.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_disk.t,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- check_disk.t	18 Oct 2006 12:12:11 -0000	1.14
+++ check_disk.t	20 Dec 2006 19:25:59 -0000	1.15
@@ -24,13 +24,13 @@
 if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
 	plan skip_all => "Need 2 mountpoints to test";
 } else {
-	plan tests => 42;
+	plan tests => 56;
 }
 
 $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)");
+cmp_ok( $result->return_code, "==", 0, "Checking two mountpoints (must have at least 1% free in space and inodes)");
 my $c = 0;
 $_ = $result->output;
 $c++ while /\(/g;	# counts number of "(" - should be two
@@ -54,6 +54,26 @@
 }
 
 
+# Do same for inodes
+$_ = $result->output;
+my ($free_inode_on_mp1, $free_inode_on_mp2) = (m/inode=(\d+)%.*inode=(\d+)%/);
+die "Cannot parse free inodes: $_" unless ($free_inode_on_mp1 && $free_inode_on_mp2);
+my $avg_inode_free = ceil(($free_inode_on_mp1 + $free_inode_on_mp2)/2);
+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) {
+	$more_inode_free = $mountpoint2_valid;
+	$less_inode_free = $mountpoint_valid;
+} else {
+	die "Two mountpoints with same inodes free - cannot do rest of test";
+}
+
+
+
+# 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" );
@@ -76,8 +96,6 @@
 like( $result->output, $failureOutput, "Right output" );
 
 
-
-
 $result = NPTest->testCmd(
 	"./check_disk -w $avg_free% -c 0% -p $less_free"
 	);
@@ -102,9 +120,6 @@
 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"
 	);
@@ -126,6 +141,50 @@
 
 
 
+# Basic inode checks for sizes
+
+$result = NPTest->testCmd( "./check_disk --icritical 1% --iwarning 1% -p $more_inode_free" );
+is( $result->return_code, 0, "At least 1% free on inodes for both mountpoints");
+
+$result = NPTest->testCmd( "./check_disk -K 100% -W 100% -p $less_inode_free" );
+is( $result->return_code, 2, "Critical requesting 100% free inodes for both mountpoints");
+
+$result = NPTest->testCmd( "./check_disk --iwarning 1% --icritical 1% -p $more_inode_free -K 100% -W 100% -p $less_inode_free" );
+is( $result->return_code, 2, "Get critical on less_inode_free mountpoint $less_inode_free");
+
+$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $less_inode_free" );
+is( $result->return_code, 1, "Get warning on less_inode_free, when checking average");
+
+$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free ");
+is( $result->return_code, 0, "Get ok on more_inode_free when checking average");
+
+$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $less_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free" );
+is ($result->return_code, 1, "Combine above two tests, get warning");
+$all_disks = $result->output;
+
+$result = NPTest->testCmd( "./check_disk -e -W $avg_inode_free% -K 0% -p $less_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free" );
+isnt( $result->output, $all_disks, "-e gives different output");
+like( $result->output, qr/$less_inode_free/, "Found problem $less_inode_free");
+unlike( $result->only_output, qr/$more_inode_free/, "Has ignored $more_inode_free as not a problem");
+like( $result->perf_output, qr/$more_inode_free/, "But $more_inode_free is still in perf data");
+
+$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $more_inode_free" );
+is( $result->return_code, 0, "Get ok on more_inode_free mountpoint, checking average");
+
+$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free" );
+is( $result->return_code, 2, "Get critical on less_inode_free, checking average");
+
+$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $more_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free" );
+is( $result->return_code, 2, "Combining above two tests, get critical");
+
+$result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free -W $avg_inode_free% -K 0% -p $more_inode_free" );
+cmp_ok( $result->return_code, '==', 2, "And reversing arguments should not make a difference");
+
+
+
+
+
+
 TODO: {
 	local $TODO = "Invalid percent figures";
 	$result = NPTest->testCmd(





More information about the Commits mailing list