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

SourceForge.net noreply at sourceforge.net
Thu May 18 05:40:04 CEST 2006


Bugs item #1485816, was opened at 2006-05-10 18:52
Message generated for change (Comment added) made by tonvoon
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: Ton Voon (tonvoon)
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: Ton Voon (tonvoon)
Date: 2006-05-18 13:39

Message:
Logged In: YES 
user_id=664364

maemigh,

Thanks for the report and the patch!

I'm not really keen on the wildcard addition. Tracker 1485683 (http://
sourceforge.net/tracker/index.php?
func=detail&aid=1485683&group_id=29880&atid=397600) could be 
overcome by using a -X cdfs option.

However, the patch for the exact name is interesting, because I think there 
are several bugs reported which this may fix. I've tried the patch out and I get 
a regression test failure. Prior to your patch, ./check_disk -p /etc would 
report the result for / (just like df /etc would). However, with the exact length 
check, check_disk now complains that /etc is not found.

Thinking some more about it, this is probably acceptable since check_disk is 
a sysadmin tool rather than a user tool. Any opinions from anyone else?

Ton

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

Comment By: maemigh (maemigh)
Date: 2006-05-11 22: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 19: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