Bug + patch: check_disk.c

Sergey Dorokhov sergey at dorokhov.com
Fri Nov 7 18:47:49 CET 2003


Hello!

I recently have discovered problem with check_disk module.
It always shows "OK" even if your free space less than critical.

Example:
# df -k /var
Filesystem     1K-blocks     Used   Avail Capacity  Mounted on
/dev/vinum/var  33646567 28453984 2500858    92%    /var

# ./check_disk -w 20 -c 10 /var
DISK OK [2500849 kB (8%) free on /dev/vinum/var]

I did some research and here is the patch.

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


--- check_disk.c        Thu Jul 10 23:03:47 2003
+++ /home/svd/check_disk.c      Fri Nov  7 09:46:19 2003
@@ -321,13 +321,13 @@ check_disk (int usp, float free_disk)
 {
        int result = STATE_UNKNOWN;
        /* check the percent used space against thresholds */
-       if (usp >= 0 && usp >= (100.0 - c_dfp))
+       if (usp >= 0 && usp >= (100.0 - c_df))
                result = STATE_CRITICAL;
-       else if (c_df >= 0 && free_disk <= c_df)
+       else if (c_df >= 0 && free_disk <= c_dfp)
                result = STATE_CRITICAL;
-       else if (usp >= 0 && usp >= (100.0 - w_dfp))
+       else if (usp >= 0 && usp >= (100.0 - w_df))
                result = STATE_WARNING;
-       else if (w_df >= 0 && free_disk <= w_df)
+       else if (w_df >= 0 && free_disk <= w_dfp)
                result = STATE_WARNING;
        else if (usp >= 0.0)
                result = STATE_OK;

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

--
Sergey Dorokhov




-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/




More information about the Developers mailing list