From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Mar 18 14:10:04 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA94C1065672 for ; Tue, 18 Mar 2008 14:10:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B80868FC16 for ; Tue, 18 Mar 2008 14:10:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m2IEA4NC078600 for ; Tue, 18 Mar 2008 14:10:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m2IEA4Zo078599; Tue, 18 Mar 2008 14:10:04 GMT (envelope-from gnats) Resent-Date: Tue, 18 Mar 2008 14:10:04 GMT Resent-Message-Id: <200803181410.m2IEA4Zo078599@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Maxim Shakhab Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 054C5106566B for ; Tue, 18 Mar 2008 14:04:00 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 055BD8FC1C for ; Tue, 18 Mar 2008 14:04:00 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m2IE3x9I011328 for ; Tue, 18 Mar 2008 14:03:59 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m2IE3xtb011327; Tue, 18 Mar 2008 14:03:59 GMT (envelope-from nobody) Message-Id: <200803181403.m2IE3xtb011327@www.freebsd.org> Date: Tue, 18 Mar 2008 14:03:59 GMT From: Maxim Shakhab To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/121830: port nagios-plugins: check_disk plugin works incorrectly X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Mar 2008 14:10:05 -0000 >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: