summaryrefslogtreecommitdiffstats
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index c32c7ab..cceb5be 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -176,6 +176,7 @@ main (int argc, char **argv)
176 struct fs_usage fsp, tmpfsp; 176 struct fs_usage fsp, tmpfsp;
177 struct parameter_list *temp_list, *path; 177 struct parameter_list *temp_list, *path;
178 struct name_list *seen = NULL; 178 struct name_list *seen = NULL;
179 struct stat *stat_buf;
179 180
180 preamble = strdup (" - free space:"); 181 preamble = strdup (" - free space:");
181 output = strdup (""); 182 output = strdup ("");
@@ -208,14 +209,22 @@ main (int argc, char **argv)
208 209
209 /* Error if no match found for specified paths */ 210 /* Error if no match found for specified paths */
210 temp_list = path_select_list; 211 temp_list = path_select_list;
212
213 stat_buf = malloc(sizeof *stat_buf);
211 while (temp_list) { 214 while (temp_list) {
212 if (! temp_list->best_match) { 215 if (! temp_list->best_match) {
213 die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); 216 die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name);
214 } 217 }
218
219 /* Stat each entry to check that dir exists */
220 if (stat (temp_list->name, &stat_buf[0])) {
221 printf("DISK %s - ", _("CRITICAL"));
222 die (STATE_CRITICAL, _("%s %s: %s\n"), temp_list->name, _("is not accessible"), strerror(errno));
223 }
215 temp_list = temp_list->name_next; 224 temp_list = temp_list->name_next;
216 } 225 }
226 free(stat_buf);
217 227
218
219 /* Process for every path in list */ 228 /* Process for every path in list */
220 for (path = path_select_list; path; path=path->name_next) { 229 for (path = path_select_list; path; path=path->name_next) {
221 230
@@ -444,7 +453,6 @@ process_arguments (int argc, char **argv)
444 struct parameter_list *temp_path_select_list = NULL; 453 struct parameter_list *temp_path_select_list = NULL;
445 struct mount_entry *me; 454 struct mount_entry *me;
446 int result = OK; 455 int result = OK;
447 struct stat *stat_buf;
448 regex_t re; 456 regex_t re;
449 int cflags = REG_NOSUB | REG_EXTENDED; 457 int cflags = REG_NOSUB | REG_EXTENDED;
450 char errbuf[MAX_INPUT_BUFFER]; 458 char errbuf[MAX_INPUT_BUFFER];
@@ -743,32 +751,7 @@ process_arguments (int argc, char **argv)
743 mult = (uintmax_t)1024 * 1024; 751 mult = (uintmax_t)1024 * 1024;
744 } 752 }
745 753
746 if (path_select_list) { 754 return TRUE;
747 temp_list = path_select_list;
748 stat_buf = malloc(sizeof *stat_buf);
749 while (temp_list) {
750 /* Stat each entry to check that dir exists */
751 if (stat (temp_list->name, &stat_buf[0])) {
752 printf("DISK %s - ", _("CRITICAL"));
753 die (STATE_CRITICAL, _("%s does not exist\n"), temp_list->name);
754 }
755 /* if (validate_arguments (temp_list->w_df,
756 temp_list->c_df,
757 temp_list->w_dfp,
758 temp_list->c_dfp,
759 temp_list->w_idfp,
760 temp_list->c_idfp,
761 temp_list->name) == ERROR)
762 result = ERROR;
763 */
764 temp_list = temp_list->name_next;
765 }
766 free(stat_buf);
767 return result;
768 } else {
769 return TRUE;
770 /* return validate_arguments (w_df, c_df, w_dfp, c_dfp, w_idfp, c_idfp, NULL); */
771 }
772} 755}
773 756
774 757