nagiosplug/plugins check_disk.c,1.91,1.92

Matthias Eble <[email protected]>
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13110/d

Modified Files:
	check_disk.c 
Log Message:
Check_disk now calls stat() for all filesystems to check.
Check_disk prints an strerror() message if the call of stat() fails.


Index: check_disk.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_disk.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- check_disk.c	3 May 2007 20:43:50 -0000	1.91
+++ check_disk.c	10 Jul 2007 20:18:55 -0000	1.92
@@ -176,6 +176,7 @@
   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 @@
 
   /* 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 @@
   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 @@
     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;
 }
 
 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.