summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f82e0df)
raw | patch | inline | side by side (parent: f82e0df)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 23 Mar 2006 17:16:38 +0000 (17:16 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 23 Mar 2006 17:16:38 +0000 (17:16 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1351 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 106e8f12a43956b6b5b38ffddbb3ccab82993172..f3fb896a3d7b210ed6d283c3e310190b48849564 100644 (file)
--- a/NPTest.pm
+++ b/NPTest.pm
sub perf_output {
my $self = shift;
$_ = $self->{output};
- s/[^|]*\|//;
- return $_;
+ /\|(.*)$/;
+ return $1 || "";
}
sub testCmd {
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index fa913ac7569a61d9ef05bbf2f9de6f6c52368a8d..c7a2b8a3aec85be79770247f193f3f519cdbf105 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
struct name_list **dptail = &dp_exclude_list;
struct name_list *temp_list;
int result = OK;
+ struct stat *stat_buf;
unsigned long l;
if (path_select_list) {
temp_list = path_select_list;
+ stat_buf = malloc(sizeof stat_buf);
while (temp_list) {
+ /* Stat each entry to check that dir exists */
+ if (stat (temp_list->name, &stat_buf[0])) {
+ printf("DISK %s - ", _("CRITICAL"));
+ die (STATE_CRITICAL, _("%s does not exist\n"), temp_list->name);
+ }
if (validate_arguments (temp_list->w_df,
temp_list->c_df,
temp_list->w_dfp,
result = ERROR;
temp_list = temp_list->name_next;
}
+ free(stat_buf);
return result;
} else {
return validate_arguments (w_df, c_df, w_dfp, c_dfp, w_idfp, c_idfp, NULL);
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index e742b5bc876749953b69be723db4795b814373d2..14bc8dedd75d766fa3346c31fa70ed7967af6981 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 => 31;
+ plan tests => 32;
}
$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 /bob" );
+cmp_ok( $result->return_code, '==', 2, "Checking /bob - return error because /bob does not exist" );
+cmp_ok( $result->output, 'eq', 'DISK CRITICAL - /bob does not exist', 'Output OK');
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /" );
my $root_output = $result->output;