[Nagiosplug-devel] [PATCH 1/1] Prevent check_swap from returning OK, if no swap activated

Thomas Guyot-Sionnest dermoth at aei.ca
Tue Apr 5 03:07:08 CEST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11-04-04 04:37 AM, Jan ONDREJ wrote:
> On Mon, Apr 04, 2011 at 01:53:27AM -0400, Thomas Guyot-Sionnest wrote:
>> On 11-04-03 03:17 AM, Peter Lemenkov wrote:
>>> My swap was not activated on boot for unknown reason and nagios does not
>>> report this as a problem. Here is an example:
>>>
>>> [root at kecom ~]# rpm -q nagios-plugins
>>> nagios-plugins-1.4.13-11.fc10.i386
>>> [root at kecom ~]# /usr/lib/nagios/plugins/check_swap -w 80% -c 40% -c 1 -w 2
>>> SWAP CRITICAL - 100% free (0 MB out of 0 MB) |swap=0MB;0;0;0;0
>>>
>>> If there is no swap and users is trying to test percentage of free swap,
>>> consider 0 MB free swap space as problem, or of free/total raises division
>>> by zero, then set percentage to 0%, not to 100%.
>>>
>>> Steps to Reproduce:
>>> 1. make sure, your swap is empty or it's usage is not large
>>> 2. swapoff -a
>>> 3. /usr/lib/nagios/plugins/check_swap -w 80% -c 40%
>>>
>>> Actual results:
>>> SWAP OK - 100% free (0 MB out of 0 MB) |swap=0MB;0;0;0;0
>>>
>>> Expected results:
>>> SWAP CRITICAL - 0% free (0 MB out of 0 MB) |swap=0MB;0;0;0;0
>>
>> You can specify an absolute value instead of percentage if you want to
>> check the presence of swap; I personally wouldn't see this as a bug, and
>> changing the default could break existing setups.
> 
> I can, but I have one configuration for all servers with different memory
> configurations, so parcentage is a best choice for me.
> 
>> Why not adding an option instead to let the user control that? It would
>> also allow passing any state this way, for instance one could want to
>> return an UNKNOWN in that case (see check_cluster; probably has some
>> handy code for that).
> 
> Sure, this problem can be handled as many concepts, byt current resolution
> is wrong. Regard no swap as OK is not a good solution, if swap space was not
> initialized corretly and there is no other swap, system mostly dies after
> all RAM is used by system.

Most of my production systems use no swap at all, or very little, even
is they have a swap partition. There are also many ppl out there that
run kernels without swapping support at all, as it save cpu cycles not
to swap (or try to swap) and some applications are much better off
dieing right away than trying to survive with swap.

In general the system itself doesn't die at all when memory run out, it
invoke the OOM killer which usually kills the most offensive app (and
can often be fine-tuned to more gracefully fail depending on actual
server setup/usage). When there is no swap, this happen very quickly,
OTOH if you have to wait until your swap partition fills up completely
your system may drag for hours and become totally useless during that
time (that's from personal experience...)

Swap check is good when you have memory leaks though... an application
will keep allocating ram and the lost bits will stack up in your swap
files. eventually swap fills up, memory usage become low and you have to
act before the server becomes unresponsive or the application crash. In
my case I have both swap and memory checks, so even on a swapless
systems I will get a memory alert if some application ends up using more
memory than expected. Therefore I don't care whenever swap is present or
not, I only care about swap over-usage and low system memory.

> 
> My C programming is not best, so I am not able to make better patch.
> If you can write another patch, for example add a switch, which can
> set critical/warning/unknown result for no swap, it can be good.

I can't do right now, but I can try to remember it - it should be
straightforward to do. Don't hesitate to bug me about it again later...

Thanks

- -- 
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2aazQACgkQ6dZ+Kt5BchZYNQCg1ErJsgJ3PqEbAOs3MoLnkmGL
elkAnRoQYTG5iFpfCHsR2Y7FRczTaBXy
=GVjH
-----END PGP SIGNATURE-----




More information about the Devel mailing list