Package: nagios-plugins
Version: 1.4-6
Severity: normal
Tags: patch

Dear Maintainer,

The check_swap plugin gives an incorrect warning about the swap usage on 
swapless systems:

SWAP UNKNOWN: -2147483548% free (0 MB out of 0 MB)

Fixing this requires a simple patch, which is attached.

Please apply.

Regards,

Allard Hoeve





-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.10-ac10-byte
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages nagios-plugins depends on:
ii  dnsutils         1:9.2.4-1               Clients provided with BIND
ii  fping            2.4b2-to-ipv6-10        sends ICMP ECHO_REQUEST packets to
ii  host             20000331-9              utility for querying DNS servers
ii  iputils-ping     3:20020927-2            Tools to test the reachability of 
ii  libc6            2.3.2.ds1-22            GNU C Library: Shared libraries an
ii  libldap2         2.1.30-8                OpenLDAP libraries
ii  libmysqlclient12 4.0.24-10               mysql database client library
ii  libnet-snmp-perl 5.0.1-1                 Script SNMP connections
ii  libpq3           7.4.7-6sarge1           PostgreSQL C client library
ii  libssl0.9.7      0.9.7e-3                SSL shared libraries
ii  ntp              1:4.2.0a+stable-2sarge1 Network Time Protocol: network uti
ii  ntp-simple       1:4.2.0a+stable-2sarge1 Network Time Protocol: daemon for 
ii  ntpdate          1:4.2.0a+stable-2sarge1 The ntpdate client for setting sys
ii  procps           1:3.2.1-2               The /proc file system utilities
ii  qstat            2.8-1                   Command-line tool for querying qua
ii  radiusclient1    0.3.2-8                 /bin/login replacement which uses 
ii  smbclient        3.0.14a-3sarge1         a LanManager-like simple client fo
ii  snmp             5.1.2-6.1               NET SNMP (Simple Network Managemen

-- no debconf information
diff -urb nagios-plugins-1.4/plugins/check_swap.c nagios-plugins-1.4.new/plugins/check_swap.c
--- nagios-plugins-1.4/plugins/check_swap.c	2005-01-19 22:14:47.000000000 +0100
+++ nagios-plugins-1.4.new/plugins/check_swap.c	2005-09-16 12:14:18.762122808 +0200
@@ -311,6 +311,7 @@
 # endif /* HAVE_SWAP */
 #endif /* HAVE_PROC_MEMINFO */
 
+	if (total_swap <= 0) {
 	percent_used = 100 * ((double) used_swap) / ((double) total_swap);
 	result = max_state (result, check_swap (percent_used, free_swap));
 	/* broken into two steps because of funkiness with builtin asprintf */
@@ -323,6 +324,14 @@
 		TRUE, (long) max (crit_size/1024, crit_percent/100.0*total_swap),
 		TRUE, 0,
 		TRUE, (long) total_swap));
+	}
+	else
+	{
+		result = STATE_OK;
+		asprintf (&status, "no swap installed");
+		asprintf (&perf,   "(N/A)");
+	}
+	
 	printf ("SWAP %s:%s |%s\n", state_text (result), status, perf);
 	return result;
 }

Reply via email to