diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_disk.c | 8 | ||||
-rw-r--r-- | plugins/t/check_disk.t | 10 |
2 files changed, 12 insertions, 6 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index fa913ac7..c7a2b8a3 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -305,6 +305,7 @@ process_arguments (int argc, char **argv) | |||
305 | struct name_list **dptail = &dp_exclude_list; | 305 | struct name_list **dptail = &dp_exclude_list; |
306 | struct name_list *temp_list; | 306 | struct name_list *temp_list; |
307 | int result = OK; | 307 | int result = OK; |
308 | struct stat *stat_buf; | ||
308 | 309 | ||
309 | unsigned long l; | 310 | unsigned long l; |
310 | 311 | ||
@@ -553,7 +554,13 @@ process_arguments (int argc, char **argv) | |||
553 | 554 | ||
554 | if (path_select_list) { | 555 | if (path_select_list) { |
555 | temp_list = path_select_list; | 556 | temp_list = path_select_list; |
557 | stat_buf = malloc(sizeof stat_buf); | ||
556 | while (temp_list) { | 558 | while (temp_list) { |
559 | /* Stat each entry to check that dir exists */ | ||
560 | if (stat (temp_list->name, &stat_buf[0])) { | ||
561 | printf("DISK %s - ", _("CRITICAL")); | ||
562 | die (STATE_CRITICAL, _("%s does not exist\n"), temp_list->name); | ||
563 | } | ||
557 | if (validate_arguments (temp_list->w_df, | 564 | if (validate_arguments (temp_list->w_df, |
558 | temp_list->c_df, | 565 | temp_list->c_df, |
559 | temp_list->w_dfp, | 566 | temp_list->w_dfp, |
@@ -564,6 +571,7 @@ process_arguments (int argc, char **argv) | |||
564 | result = ERROR; | 571 | result = ERROR; |
565 | temp_list = temp_list->name_next; | 572 | temp_list = temp_list->name_next; |
566 | } | 573 | } |
574 | free(stat_buf); | ||
567 | return result; | 575 | return result; |
568 | } else { | 576 | } else { |
569 | return validate_arguments (w_df, c_df, w_dfp, c_dfp, w_idfp, c_idfp, NULL); | 577 | 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 e742b5bc..14bc8ded 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -22,7 +22,7 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth | |||
22 | if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { | 22 | if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { |
23 | plan skip_all => "Need 2 mountpoints to test"; | 23 | plan skip_all => "Need 2 mountpoints to test"; |
24 | } else { | 24 | } else { |
25 | plan tests => 31; | 25 | plan tests => 32; |
26 | } | 26 | } |
27 | 27 | ||
28 | $result = NPTest->testCmd( | 28 | $result = NPTest->testCmd( |
@@ -157,11 +157,9 @@ TODO: { | |||
157 | $result = NPTest->testCmd( "./check_disk 200 0 $mountpoint_valid" ); | 157 | $result = NPTest->testCmd( "./check_disk 200 0 $mountpoint_valid" ); |
158 | cmp_ok( $result->return_code, '==', 3, "Old syntax: Error with values outside percent range" ); | 158 | cmp_ok( $result->return_code, '==', 3, "Old syntax: Error with values outside percent range" ); |
159 | 159 | ||
160 | TODO: { | 160 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /bob" ); |
161 | local $TODO = "Check existence of each filesystem as a directory"; | 161 | cmp_ok( $result->return_code, '==', 2, "Checking /bob - return error because /bob does not exist" ); |
162 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /bob" ); | 162 | cmp_ok( $result->output, 'eq', 'DISK CRITICAL - /bob does not exist', 'Output OK'); |
163 | cmp_ok( $result->return_code, '==', 2, "Checking /bob - return error because /bob does not exist" ); | ||
164 | } | ||
165 | 163 | ||
166 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /" ); | 164 | $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /" ); |
167 | my $root_output = $result->output; | 165 | my $root_output = $result->output; |