[Nagiosplug-devel] Bug in check_swap

Flo Gleixner flo at bier.homeip.net
Mon Mar 1 20:25:48 CET 2004


Maybe a parsing bug, but it doesn't check for division by zero also:

swapoff -a
/usr/local/nagios/libexec/check_swap -w 80% -c 90%
CRITICAL - Swap used: -2147483648% (0 out of 0)

lines 94ff

    if (allswaps) {
             percent = 100 * (((double) dskused) / ((double) dsktotal));
             result = max_state (result, check_swap (percent, dskfree));

should probably:

    if (allswaps) {
	if(dsktotal==0) {
		percent=100.0;
	} else {
		percent = 100 * (((double) dskused) / ((double) dsktotal));
	}

or something like that

Flo

On Fri, 27 Feb 2004, Voon, Ton wrote:

> Hampus,
>
> I think you're right. Code looks like it only expects the 2.4 version of
> output, ie, the first line of information. Looks like the change is to parse
> for SwapCached, SwapTotal and SwapFree instead.
>
> Thanks for the bug report - I've raised it on SF:
> http://sourceforge.net/tracker/index.php?func=detail&aid=905971&group_id=298
> 80&atid=397597 so I don't lose sight of this.
>
> I'll have a go, but probably not until next week. If you can provide a
> patch, I'll be happy to accept.
>
> Ton
>
> -----Original Message-----
> From: Hampus Linden [mailto:hampus at activemediatech.com]
> Sent: Friday, February 27, 2004 4:10 PM
> To: nagiosplug-devel at lists.sourceforge.net
> Subject: Re: [Nagiosplug-devel] Bug in check_swap
>
>
> My own assumption is the bug is caused by the restructuring of /proc/meminfo
> in kernel 2.6
>
> 2.4 outputs all swap info on one line as well as on separate lines.
>
> 2.4: cat /proc/meminfo  |grep -i swap
> Swap: 4145455104  1544192 4143910912
> SwapCached:        316 kB
> SwapTotal:     4048296 kB
> SwapFree:      4046788 kB
>
> 2.6: cat /proc/meminfo |grep -i swap
> SwapCached:          0 kB
> SwapTotal:     2097144 kB
> SwapFree:      2097144 kB
>
> -----Original Message-----
> From: nagiosplug-devel-admin at lists.sourceforge.net
> [mailto:nagiosplug-devel-admin at lists.sourceforge.net] On Behalf Of
> Voon, Ton
> Sent: 27 February 2004 15:00
> To: 'Hampus Linden'; nagiosplug-devel at lists.sourceforge.net
> Subject: RE: [Nagiosplug-devel] Bug in check_swap
>
> Hampus,
>
> Which version of check_swap are you using? Which OS?
>
> Can you send the output from a check_swap -v -v -v -w 90% -c 95%?
>
> Ton
>
> -----Original Message-----
> From: Hampus Linden [mailto:hampus at activemediatech.com]
> Sent: Friday, February 27, 2004 1:18 PM
> To: nagiosplug-devel at lists.sourceforge.net
> Subject: [Nagiosplug-devel] Bug in check_swap
>
>
> Hi,
>
> I have some strange behavior with check_swap and large swap slices.
>
> [root at devapp01 /]# /usr/libexec/nrpe/check_swap -w 90% -c 95%
> CRITICAL - Swap used: -2147483648% (0 out of 0)
>
> Other usefull output:
> [root at devapp01 /]# swapon -s
> Filename                                Type            Size    Used
> Priority
> /dev/mapper/Volume00-LogVol03            partition      3248120 5876    -1
>
> [root at devapp01 /]# free
>              total       used       free     shared    buffers     cached
> Mem:       2072100    2045116      26984          0     271048    1557352
> -/+ buffers/cache:     216716    1855384
> Swap:      3248120       5876    3242244
>
> Thanks.
>
> Hampus Linden
> System Administrator | Active Media
> www.activemediatech.com
>
>
> This private and confidential e-mail has been sent to you by Egg.
> The Egg group of companies includes Egg Banking plc
> (registered no. 2999842), Egg Financial Products Ltd (registered
> no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
> is authorised and regulated by the Financial Services Authority. Egg
> Investments Ltd. is entered in the FSA register under number 190518.
>
> Registered in England and Wales. Registered offices: 1 Waterhouse
> Square, 138-142 Holborn, London EC1N 2NA.
>
> If you are not the intended recipient of this e-mail and have received
> it in error, please notify the sender by replying with 'received in
> error' as the subject and then delete it from your mailbox.
>
>
>
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> Nagiosplug-devel mailing list
> Nagiosplug-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
> ::: Please include plugins version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
>





More information about the Devel mailing list