aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils_disk.c
diff options
context:
space:
mode:
authorGravatar Ton Voon <tonvoon@users.sourceforge.net> 2006-07-12 19:30:20 +0000
committerGravatar Ton Voon <tonvoon@users.sourceforge.net> 2006-07-12 19:30:20 +0000
commit4edea20b86fb08209ffb38c77be2df1d3a373e82 (patch)
treecb53837ed7bd59ee53f83df6f50e01fa446ff399 /plugins/utils_disk.c
parentee03f1415acc9f4f8901593d9045244fbb3bbbb0 (diff)
downloadmonitoring-plugins-4edea20b86fb08209ffb38c77be2df1d3a373e82.tar.gz
Moving parameter_list into utils_disk.h. Given list of mount points, can
now work out best match or exact match. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1448 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils_disk.c')
-rw-r--r--plugins/utils_disk.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/utils_disk.c b/plugins/utils_disk.c
index 6380df35..0a71d792 100644
--- a/plugins/utils_disk.c
+++ b/plugins/utils_disk.c
@@ -43,6 +43,60 @@ np_add_name (struct name_list **list, const char *name)
*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)