mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-05-28 04:35:40 -04:00
Check_disk now calls stat() for all filesystems to check.
Check_disk prints an strerror() message if the call of stat() fails. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1754 f882894a-f735-0410-b71e-b25c423dba1c
This commit is contained in:
parent
5d11612ecb
commit
5e633124e4
3 changed files with 14 additions and 29 deletions
2
NEWS
2
NEWS
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue