Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Mar 2008 14:03:59 GMT
From:      Maxim Shakhab <maxim.shakhab@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/121830: port nagios-plugins: check_disk plugin works incorrectly
Message-ID:  <200803181403.m2IE3xtb011327@www.freebsd.org>
Resent-Message-ID: <200803181410.m2IEA4Zo078599@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         121830
>Category:       ports
>Synopsis:       port nagios-plugins: check_disk plugin works incorrectly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 18 14:10:04 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Maxim Shakhab
>Release:        FreeBSD-CURRENT
>Organization:
KL
>Environment:
>Description:
I investigated the situation, when check_disk plugin
works incorrectly.

When any filesystem is full like this:

Filesystem        1K-blocks    Used   Avail Capacity
Mounted on
100%    /dev
/dev/mirror/m0s1d    118766  109548    -282
100%    /tmp

check_disk plugin lies:

# ./check_disk -p /dev/mirror/m0s1d -w 20% -c 10%
DISK CRITICAL - free space: /tmp 36028797018963968 MB
(31064015077900328%
inode=99%);| /tmp=116MB;92;103;98;115

You see the sign of signed operand is ignored, and as
a result we have incorrect size of filesystem's free
space.

I took a look at two files: check_disk.c and fsusage.h
and found several errors. I corrected them, built
check_disk, and afterwards everything is ok: it shows
correct information about free space and works
properly:

# ./check_disk -p /dev/mirror/m0s1d -w 20% -c 10%
DISK CRITICAL - free space: /tmp -0 MB (-0%
inode=99%);| /tmp=116MB;92;103;98;115

>How-To-Repeat:
any filesystem is full

>Fix:
These are diffs:

# diff fsusage.h.new  fsusage.h.orig
28,29c28,29
<   intmax_t fsu_bfree;         /* Free blocks
available to superuser. */
<   intmax_t fsu_bavail;                /* Free blocks
available to non-superuser. */
---
>   uintmax_t fsu_bfree;                /* Free blocks
available to superuser. */
>   uintmax_t fsu_bavail;               /* Free blocks
available to non-superuser. */

# diff check_disk.c.new  check_disk.c.orig
160c160
<   double free_space, free_space_pct, total_space,
inode_space_pct;
---
>   float free_space, free_space_pct, total_space,
inode_space_pct;
256,258c256,258
<       free_space = (double)
fsp.fsu_bavail*fsp.fsu_blocksize/mult;
<       free_space_pct = (double)
fsp.fsu_bavail*100/fsp.fsu_blocks;
<       total_space = (double)
fsp.fsu_blocks*fsp.fsu_blocksize/mult;
---
>       free_space = (float)
fsp.fsu_bavail*fsp.fsu_blocksize/mult;
>       free_space_pct = (float)
fsp.fsu_bavail*100/fsp.fsu_blocks;
>       total_space = (float)
fsp.fsu_blocks*fsp.fsu_blocksize/mult;


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803181403.m2IE3xtb011327>