diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | plugins/check_disk.c | 39 | ||||
-rw-r--r-- | plugins/t/check_disk.t | 2 |
3 files changed, 14 insertions, 29 deletions
@@ -4,6 +4,8 @@ This file documents the major additions and syntax changes between releases. Fix check_http buffer overflow vulnerability when following HTTP redirects Check_ldaps' guessing which secure method to use (starttls vs. ssl on connect) is now deprecated. See --help for further information. + Check_disk now calls stat() on all filesystems to check. (Old: only the ones selected using -p) + A meaningful error message (eg "Stale NFS Handle") is printed if stat fails. 1.4.9 4th June 2006 Inclusion of contrib/check_cluster2 as check_cluster with some improvements diff --git a/plugins/check_disk.c b/plugins/check_disk.c index c32c7ab3..cceb5be8 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -176,6 +176,7 @@ main (int argc, char **argv) struct fs_usage fsp, tmpfsp; struct parameter_list *temp_list, *path; struct name_list *seen = NULL; + struct stat *stat_buf; preamble = strdup (" - free space:"); output = strdup (""); @@ -208,14 +209,22 @@ main (int argc, char **argv) /* Error if no match found for specified paths */ temp_list = path_select_list; + + stat_buf = malloc(sizeof *stat_buf); while (temp_list) { if (! temp_list->best_match) { die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); } + + /* Stat each entry to check that dir exists */ + if (stat (temp_list->name, &stat_buf[0])) { + printf("DISK %s - ", _("CRITICAL")); + die (STATE_CRITICAL, _("%s %s: %s\n"), temp_list->name, _("is not accessible"), strerror(errno)); + } temp_list = temp_list->name_next; } + free(stat_buf); - /* Process for every path in list */ for (path = path_select_list; path; path=path->name_next) { @@ -444,7 +453,6 @@ process_arguments (int argc, char **argv) struct parameter_list *temp_path_select_list = NULL; struct mount_entry *me; int result = OK; - struct stat *stat_buf; regex_t re; int cflags = REG_NOSUB | REG_EXTENDED; char errbuf[MAX_INPUT_BUFFER]; @@ -743,32 +751,7 @@ process_arguments (int argc, char **argv) mult = (uintmax_t)1024 * 1024; } - 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, - temp_list->c_dfp, - temp_list->w_idfp, - temp_list->c_idfp, - temp_list->name) == ERROR) - result = ERROR; - */ - temp_list = temp_list->name_next; - } - free(stat_buf); - return result; - } else { - return TRUE; - /* return validate_arguments (w_df, c_df, w_dfp, c_dfp, w_idfp, c_idfp, NULL); */ - } + return TRUE; } diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index 5c6aa39a..4f5c4bc4 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t @@ -275,7 +275,7 @@ TODO: { $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'); +like( $result->output, '/^DISK CRITICAL - /bob is not accessible:.*$/', 'Output OK'); $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p /" ); my $root_output = $result->output; |