[Nagiosplug-devel] check_swap divide by 0 error
Nik Sands
Nik.Sands at utas.edu.au
Tue Jun 28 11:08:38 CEST 2005
The "check_swap" nagios plugin has a minor flaw, in that the output
is incorrect for machines with no swap configured (at least on
Solaris). Some people may say, "well, you should have swap
configured!", but when the machine has 16 GB of RAM, it really isn't
necessary. In any case, it should at least show the correct
percentage used, which would be either 100% (and warning or critical)
or 0%. As it is it get's the result of a divide by zero, which is
rather ugly.
The line of code is question is:
percent_used = 100 * ((double) used_swap) / ((double)
total_swap);
When there's no swap, this amounts to:
percent_used = 100 * 0 / 0;
If would be good to have a block before this, something like:
if ( total_swap == 0 )
{
/* percent_used = either 0 or 100, depending on your
point of view */
}
else
Thanks for your consideration of this imporovement.
Please note that I'm not a member of this list so won't see any
responses posted to the list. If I need to see any responses (which
I doubt), please CC them to me.
Cheers,
Nik.
========================================================
NIK SANDS - Systems Administrator, IT Services, University of
Tasmania, Australia
Phone: +61-3-63243732 (BH)
VoIP (Free Call): (1800 262 218) 393 658821
AIM / iChat: brassnix
More information about the Devel
mailing list