[Nagiosplug-devel] [ nagiosplug-Bugs-1485816 ] check_disk exclude option always exludes (/)

SourceForge.net noreply at sourceforge.net
Thu May 11 14:54:01 CEST 2006


Bugs item #1485816, was opened at 2006-05-10 13:52
Message generated for change (Comment added) made by maemigh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1485816&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: maemigh (maemigh)
Assigned to: Nobody/Anonymous (nobody)
Summary: check_disk exclude option always exludes (/)

Initial Comment:
check_disk (1.64) always exludes (/) when using -x.

For example, the output below shows that using -x /var
also causes the (/) directory to be excluded.

./check_disk -w 10% -c 5%
DISK WARNING - free space: / 4153 MB (69% inode=90%);
/var 5660 MB (94% inode=99%); /var/run 4369 MB (100%
inode=64%); /tmp 4369 MB (81% inode=64%); /opt 16292 MB
(90% inode=98%); /home/applications 20110 MB (50%
inode=95%);

./check_disk -w 10% -c 5% -x /var
DISK OK - free space: /var/run 4369 MB (100%
inode=64%); /tmp 4369 MB (81% inode=64%); /opt 16292 MB
(90% inode=98%); /home/applications 20110 MB (50%
inode=95%);

----------------------------------------------------------------------

>Comment By: maemigh (maemigh)
Date: 2006-05-11 17:53

Message:
Logged In: YES 
user_id=1520524

I forgot to mention that it appeared the plugin was trying
to exlude everything that stems from a path when used with
-x (although the function was broken).  I've implemented it
with a wildcard because you may have a mount within the
directory of another mount.  In the case above, if we were
to use the old method, not only would /var be excluded, but
also /var/run (and this is not desired).

----------------------------------------------------------------------

Comment By: maemigh (maemigh)
Date: 2006-05-11 14:20

Message:
Logged In: YES 
user_id=1520524

I modified the walk_name_list function to operate properly.
Additionally, my changes took care of my feature request
(1485683) as well.  I tried every test case I could think of
and the code seemed to work properly.  Please review for
correctness and efficiency.
int
walk_name_list (struct name_list *list, const char *name)
{
  int name_len;
  name_len = strlen(name);
  while (list) {
    /* if the paths match up to the length of the search path,
     * AND if the paths names are the same length then we
have a winner.
     * OR if the search path is shorter than the mount path and
     * ends with the wildcard '*' we have a winner.
     * The wildcard character must be escaped out, thus
list_name_len-2 */
    int list_name_len;
    list_name_len = strlen(list->name);
    if ((name_len == list_name_len &&
         strncmp(list->name, name, list_name_len) == 0) ||
(name_len >= list_name_len && strncmp(list->name, name,
list_name_len-2) == 0 &&
strncmp(&list->name[list_name_len-1], "*", 1) == 0)) {
      list->found = 1;
      list->found_len = name_len;
      /* if required for name_lists that have not saved
w_df, etc (eg exclude lists) */
      if (list->w_df) w_df = list->w_df;
      if (list->c_df) c_df = list->c_df;
      if (list->w_dfp>=0.0) w_dfp = list->w_dfp;
      if (list->c_dfp>=0.0) c_dfp = list->c_dfp;
      return TRUE;
    }
    list = list->name_next;
  }
  return FALSE;
}


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1485816&group_id=29880




More information about the Devel mailing list