summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5d11612)
raw | patch | inline | side by side (parent: 5d11612)
author | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Tue, 10 Jul 2007 20:18:55 +0000 (20:18 +0000) | ||
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Tue, 10 Jul 2007 20:18:55 +0000 (20:18 +0000) |
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
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1754 f882894a-f735-0410-b71e-b25c423dba1c
NEWS | patch | blob | history | |
plugins/check_disk.c | patch | blob | history | |
plugins/t/check_disk.t | patch | blob | history |
index 81e1bfb50441e8b00d8bb62146f27fac3e2010bb..7085e5c801c8b234a889b6f0857605c8991d7f13 100644 (file)
--- a/NEWS
+++ b/NEWS
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 c32c7ab3eb80e939c974c222dbab50b6a4f93285..cceb5be8c8d326b224eaeb6686399eb7a69a3ac9 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
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 ("");
/* 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) {
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];
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 5c6aa39a3538713369379961d7283fb669ff8706..4f5c4bc4a9ce2100ceded22555a7add9f982d304 100644 (file)
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
$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;