[Nagiosplug-devel] Bug and fix for the check_disk plugin

Erik Welch ewelch at nvidia.com
Thu Nov 6 23:07:26 CET 2008

Bug in plugins/check_disk.c from nagios-plugins-1.4.12 (and prior)
* $Id: check_disk.c 1991 2008-05-07 10:02:42Z dermoth $

The program collects the mounted filesystem data before it processes the command line arguments. This is a problem for multiple reasons:
* Why spend cycles on the filesystem if there is an error or --help in the arguments?
* The argument processing stats the -p options to mount them in an autofs environment, but they won't have been mounted yet...

Detailed output showing the autofs problem:
$ sudo umount /home/userdir
$ plugins/check_disk -w 5% -c 1% -vvvvv -e -p /home/userdir
calling stat on /home/userdir
Thresholds(pct) for /home/userdir warn: 5.000000 crit 1.000000
calling stat on /home/userdir
DISK UNKNOWN - free space:|

Simply changing the order of the mount_list creation does not fix the problem as process_arguments uses the mount list in calls to np_set_best_match(), but does nothing with the results.  I commented them and now the program works as it should.

Diff output:
$ diff check_disk.c check_disk.c.new
<   mount_list = read_file_system_list (0);
>   mount_list = read_file_system_list (0);
<       np_set_best_match(se, mount_list, exact_match);
>       /* np_set_best_match(se, mount_list, exact_match); */
<       np_set_best_match(path_select_list, mount_list, exact_match);
>       /* np_set_best_match(path_select_list, mount_list, exact_match); */

Detailed output from fixed binary:
$ sudo umount /home/userdir
$ plugins/check_disk.new -w 5% -c 1% -vvvvv -e -p /home/userdir
calling stat on /home/userdir
Thresholds(pct) for /home/userdir warn: 5.000000 crit 1.000000
calling stat on /home/userdir
For /home/userdir, total=2129920, available=1047846, available_to_root=1047846, used=1082074, fsp.fsu_files=4133162, fsp.fsu_ffree=4031760
For /home/userdir, used_pct=51 free_pct=49 used_units=33814 free_units=32745 total_units=66560 used_inodes_pct=3 free_inodes_pct=97 fsp.fsu_blocksize=32768 mult=1048576
Freespace_units result=0
Freespace% result=0
Usedspace_units result=0
Usedspace_percent result=0
Usedinodes_percent result=0
Freeinodes_percent result=0
DISK OK /home/userdir 32745 MB (49% inode=97%);| /home/userdir=33814MB;63232;65894;0;66560


Erik Welch - Unix Administrator
2701 San Tomas Expwy
Santa Clara, CA 95050

This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20081106/e0da13cf/attachment.html>

More information about the Devel mailing list