summaryrefslogtreecommitdiffstats
path: root/monitoring-plugins/monitoring-plugins-0005-Prevent-check_swap-from-returning-OK-if-no-swap-acti.patch
blob: fb3d437e03f47d522842324a946d873cde6fad4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From b6d2006d773e492f69abe2843e67a7eba2cfc415 Mon Sep 17 00:00:00 2001
From: Jan ONDREJ <ondrejj@salstar.sk>
Date: Thu, 7 Oct 2010 17:28:48 +0400
Subject: [PATCH 05/10] Prevent check_swap from returning OK, if no swap
 activated

My swap was not activated on boot for unknown reason and nagios does not
report this as a problem. Here is an example:

[root@kecom ~]# rpm -q nagios-plugins
nagios-plugins-1.4.13-11.fc10.i386
[root@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

Additional info:
https://bugzilla.redhat.com/512559
---
 plugins/check_swap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index ce1f602..6d1d0c1 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -124,7 +124,7 @@ main (int argc, char **argv)
 			free_swap_mb += dskfree_mb;
 			if (allswaps) {
 				if (dsktotal_mb == 0)
-					percent=100.0;
+					percent = 0.0;
 				else
 					percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
 				result = max_state (result, check_swap (percent, dskfree_mb));
-- 
1.8.3.1