check_disk now errors if a specified directory does not exist (cf df /foo)

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1351 f882894a-f735-0410-b71e-b25c423dba1c
This commit is contained in:
Ton Voon 2006-03-23 17:16:38 +00:00
parent f82e0dfa81
commit ada5f2fe02
3 changed files with 14 additions and 8 deletions

View file

@ -599,8 +599,8 @@ sub output {
sub perf_output {
my $self = shift;
$_ = $self->{output};
s/[^|]*\|//;
return $_;
/\|(.*)$/;
return $1 || "";
}
sub testCmd {

View file

@ -305,6 +305,7 @@ process_arguments (int argc, char **argv)
struct name_list **dptail = &dp_exclude_list;
struct name_list *temp_list;
int result = OK;
struct stat *stat_buf;
unsigned long l;
@ -553,7 +554,13 @@ process_arguments (int argc, char **argv)
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,
@ -564,6 +571,7 @@ process_arguments (int argc, char **argv)
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);

View file

@ -22,7 +22,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 => 31;
plan tests => 32;
}
$result = NPTest->testCmd(
@ -157,11 +157,9 @@ TODO: {
$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;