summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ebbe5c)
raw | patch | inline | side by side (parent: 3ebbe5c)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 23 Mar 2006 12:01:21 +0000 (12:01 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 23 Mar 2006 12:01:21 +0000 (12:01 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1349 f882894a-f735-0410-b71e-b25c423dba1c
NPTest.pm | patch | blob | history | |
plugins/check_disk.c | patch | blob | history | |
plugins/t/check_disk.t | patch | blob | history |
diff --git a/NPTest.pm b/NPTest.pm
index f1ff801e309b5a9ddec2d9bf1f706e853a174d6a..106e8f12a43956b6b5b38ffddbb3ccab82993172 100644 (file)
--- a/NPTest.pm
+++ b/NPTest.pm
}
}
+sub perf_output {
+ my $self = shift;
+ $_ = $self->{output};
+ s/[^|]*\|//;
+ return $_;
+}
+
sub testCmd {
my $class = shift;
my $command = shift or die "No command passed to testCmd";
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 0ee6dc87897b923bccbae44744c8e1b89744a221..fa913ac7569a61d9ef05bbf2f9de6f6c52368a8d 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
}
- asprintf (&output, "%s|%s", output, perf);
-
if (verbose > 2)
asprintf (&output, "%s%s", output, details);
temp_list = temp_list->name_next;
}
- printf ("DISK %s%s\n", state_text (result), output);
+ printf ("DISK %s%s|%s\n", state_text (result), output, perf);
return result;
}
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index 385865fe9e89860f2210911130760a42a9abf78b..90ccc26a54d182602db8f27bb464355ca0086abe 100644 (file)
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
plan skip_all => "Need 2 mountpoints to test";
} else {
- plan tests => 26;
+ plan tests => 31;
}
$result = NPTest->testCmd(
$result = NPTest->testCmd( "./check_disk 200 0 $mountpoint_valid" );
cmp_ok( $result->return_code, '==', 3, "Old syntax: Error with values outside percent range" );
+TODO: {
+ local $TODO = "Check existence of each filesystem as a directory";
+ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /bob" );
+ cmp_ok( $result->return_code, '==', 2, "Checking /bob - return error because /bob does not exist" );
+}
+
+$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /" );
+my $root_output = $result->output;
+
+$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /etc" );
+cmp_ok( $result->return_code, '==', 0, "Checking /etc - should return info for /" );
+cmp_ok( $result->output, 'eq', $root_output, "check_disk /etc gives same as check_disk /");
+
+$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p / -p /bob" );
+cmp_ok( $result->return_code, '==', 2, "Checking / and /bob gives critical");
+unlike( $result->perf_output, 'm#/bob#', "perf data does not have /bob in it");