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

SourceForge.net noreply at sourceforge.net
Fri Nov 3 04:20:07 CET 2006


Bugs item #1485816, was opened at 2006-05-10 10:52
Message generated for change (Comment added) made by sf-robot
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: Closed
Resolution: None
Priority: 5
Private: No
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: SourceForge Robot (sf-robot)
Date: 2006-11-02 19:20

Message:
Logged In: YES 
user_id=1312539

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

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

Comment By: Ton Voon (tonvoon)
Date: 2006-10-19 12:44

Message:
Logged In: YES 
user_id=664364

maemigh,

Am I right in saying this can be closed now? I'll mark into pending so it will auto 
close after 7 days. Please update if it is still an issue.

Ton

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

Comment By: Ton Voon (tonvoon)
Date: 2006-07-19 16:12

Message:
Logged In: YES 
user_id=664364

maemigh,

I'm made some major changes to check_disk which should fix the original 
problem.

One change was to move the filesystem comparisons out into utils_disk.c. I'd 
definitely be interested in your wildcard patch if you can add it into 
utils_disk.c with some libtap tests in lib/tests/test_disk.c.

Ton


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

Comment By: maemigh (maemigh)
Date: 2006-05-21 17:04

Message:
Logged In: YES 
user_id=1520524

Sorry for so many updates.  I don't know how I missed a
small bug.  I set the comment in the file for what I meant
to happen, but forgot to change the values after I pasted
it.  I retested it (now that I'm wide awake) and it seems to
be working as expected.

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

Comment By: maemigh (maemigh)
Date: 2006-05-20 18:47

Message:
Logged In: YES 
user_id=1520524

Uploading version 1.65.3m.  This one adds slightly better
HTML formatted text (places *s around the partition that
triggered the alarm) and adds an -a option.
The -a option tells check_disk to display all partitions
even if -p is also specified:
Example
check_disk -w 10% -c 5% -a -C -w 5% -c 3% -p /
    Checks / at 5% and 3% and every other mount at 10% and 5%

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

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

Message:
Logged In: YES 
user_id=1520524

Forgot to mention:
-p should be working the same way it has been in the past.

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

Comment By: maemigh (maemigh)
Date: 2006-05-20 00:12

Message:
Logged In: YES 
user_id=1520524

I didn't test the last upload enough, so I removed it.

I've added lots of additional code to check_disk and I've
tested it with every scenario I could think of (including
the one you mentioned earlier).  It all seems to work
properly now.  I have added several new features as well:
-x will exclude a mount point that matches exactly
-s will exclude a path and any mount points within
-U outputs the percentages in terms of used space/inodes
-H formats the output in HTML (makes it really easy to read
on the status page)

I think I'm going to continue working on it as I might want
the ability to specify different warn/crit percentages for
different mount points; any suggestions on how to go about
doing that would be nice :)

I've attached the file, versioned 1.65.1

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

Comment By: maemigh (maemigh)
Date: 2006-05-18 08:39

Message:
Logged In: YES 
user_id=1520524

To answer your question, -X cdfs will not work.  The cdrom
mount is all ufs and -X ufs will exclude a few extra partitions.

I've gone and recoded the file.  I've added an extra switch
(-s) which will exclude an entire path structure whereas -x
will only exclude exact matches.  (ie -x /var will NOT
exclude /var/run; -s /var WILL exclude both /var and
/var/run).  This code should also behave the same way it
used to -- -p /etc will include (/).

I've attached a copy of the whole file.


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

Comment By: Ton Voon (tonvoon)
Date: 2006-05-18 05: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 14: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 11: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