[Nagiosplug-checkins] nagiosplug/plugins check_disk.c, 1.69, 1.70 utils_disk.c, 1.1, 1.2 utils_disk.h, 1.1, 1.2

Ton Voon tonvoon at users.sourceforge.net
Wed Jul 12 21:30:22 CEST 2006


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv11884

Modified Files:
	check_disk.c utils_disk.c utils_disk.h 
Log Message:
Moving parameter_list into utils_disk.h. Given list of mount points, can
now work out best match or exact match.


Index: utils_disk.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils_disk.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- utils_disk.c	12 Jul 2006 12:15:42 -0000	1.1
+++ utils_disk.c	12 Jul 2006 19:30:20 -0000	1.2
@@ -43,6 +43,60 @@
   *list = new_entry;
 }
 
+void
+np_add_parameter(struct parameter_list **list, const char *name)
+{
+  struct parameter_list *new_path;
+  new_path = (struct parameter_list *) malloc (sizeof *new_path);
+  new_path->name = (char *) name;
+  new_path->found = 0;
+  new_path->found_len = 0;
+  new_path->w_df = 0;
+  new_path->c_df = 0;
+  new_path->w_dfp = -1.0;
+  new_path->c_dfp = -1.0;
+  new_path->w_idfp = -1.0;
+  new_path->c_idfp = -1.0;
+  new_path->name_next = *list;
+  *list = new_path;
+}
+
+void
+np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact)
+{
+  struct parameter_list *d;
+  for (d = desired; d; d= d->name_next) {
+    struct mount_entry *me;
+    size_t name_len = strlen(d->name);
+    size_t best_match_len = 0;
+    struct mount_entry *best_match = NULL;
+
+    for (me = mount_list; me; me = me->me_next) {
+      size_t len = strlen (me->me_mountdir);
+      if ((exact == FALSE && (best_match_len <= len && len <= name_len && 
+        (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
+	|| (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
+      {
+        best_match = me;
+        best_match_len = len;
+      } else {
+        len = strlen (me->me_devname);
+        if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
+          (len == 1 || strncmp (me->me_devname, d->name, len) == 0)))
+          || (exact == TRUE && strcmp(me->me_devname, d->name)==0))
+        {
+          best_match = me;
+          best_match_len = len;
+        }
+      }
+    }
+    if (best_match) {
+      d->best_match = best_match;
+      d->found = TRUE;
+    }
+  }
+}
+
 /* Returns TRUE if name is in list */
 int
 np_find_name (struct name_list *list, const char *name)

Index: check_disk.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_disk.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- check_disk.c	12 Jul 2006 12:15:42 -0000	1.69
+++ check_disk.c	12 Jul 2006 19:30:20 -0000	1.70
@@ -74,21 +74,6 @@
    SunOs4.1.3, for one.  It is *not* necessary on Linux.  */
 /* static int require_sync = 0; */
 
-/* A filesystem type to display. */
-struct parameter_list
-{
-  char *name;
-  int found;
-  int found_len;
-  uintmax_t w_df;
-  uintmax_t c_df;
-  double w_dfp;
-  double c_dfp;
-  double w_idfp;
-  double c_idfp;
-  struct parameter_list *name_next;
-};
-
 /* Linked list of filesystem types to display.
    If `fs_select_list' is NULL, list all types.
    This table is generated dynamically from command-line options,

Index: utils_disk.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils_disk.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- utils_disk.h	12 Jul 2006 12:15:42 -0000	1.1
+++ utils_disk.h	12 Jul 2006 19:30:20 -0000	1.2
@@ -1,5 +1,6 @@
 /* Header file for utils_disk */
 
+#include "mountlist.h"
 
 struct name_list
 {
@@ -7,6 +8,22 @@
   struct name_list *next;
 };
 
+struct parameter_list
+{
+  char *name;
+  int found;
+  int found_len;
+  uintmax_t w_df;
+  uintmax_t c_df;
+  double w_dfp;
+  double c_dfp;
+  double w_idfp;
+  double c_idfp;
+  struct mount_entry *best_match;
+  struct parameter_list *name_next;
+};
+
 void np_add_name (struct name_list **list, const char *name);
 int np_find_name (struct name_list *list, const char *name);
-
+void np_add_parameter(struct parameter_list **list, const char *name);
+int search_parameter_list (struct parameter_list *list, const char *name);





More information about the Commits mailing list