From:
[email protected]
This is a multi-part MIME message sent by reportbug.
Package: nagios-plugins
Version: 1.3.1.0-8
Severity: minor
Tags: patch
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
this is a real corner case, but it's a pretty simple fix. if you
run check_swap on a system without swap[1], you get an
error message something like:
CRITICAL - Swap used: -2147483648% (0 out of 0)
the fix is simple enough. test to see that both the swap used
and swap free are > 0 before turning them into doubles, otherwise
make the percentage free 0. patch attached. note: i wasn't sure
whether to patch the patched source, or the pristine source, as
one way would conflict with the other.
sean
[1] yes, it doesn't make all that much sense to run check_swap on
a system without swap (or have a system without swap, for that
matter, though i could probably conjure up a few valid cases),
which is why i gave Severity: minor.
- -- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.7-1-686
Locale: LANG=en_US, LC_CTYPE=en_US
Versions of packages nagios-plugins depends on:
ii dnsutils 1:9.2.3-3 Clients provided with BIND
ii fping 2.4b2-to-ipv6-7 Send ICMP ECHO_REQUEST packets to ii host 20000331-9 utility for querying DNS servers ii libc6 2.3.2.ds1-11 GNU C Library: Shared libraries an ii libldap2 2.1.29-2 OpenLDAP libraries
ii libmysqlclient10 3.23.56-2 LGPL-licensed client library for M ii libnet-snmp-perl 4.0.3-1 Script SNMP connections
ii libpq3 7.4.2-3 Shared library libpq.so.3 for Post ii libssl0.9.7 0.9.7d-1 SSL shared libraries
ii netkit-ping [ping] 0.10-9 The ping utility from netkit
ii ntp-simple 1:4.1.2a-2 NTP v4 daemon for simple systems ii ntpdate 1:4.2.0a-11 The ntpdate client for setting sys ii procps 1:3.2.1-2 The /proc file system utilities
ii qstat 2.5c-3 Command-line tool for querying qua ii radiusclient1 0.3.2-6 /bin/login replacement which uses ii smbclient 3.0.2a-1 a LanManager-like simple client fo ii snmp 5.1.1-2 NET SNMP (Simple Network Managemen
- -- no debconf information
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBGqeeynjLPm522B0RAhBVAJ9Eu7IvMcfS9bgUnxVPMTxA0wTPDgCfX2+U VRjtk7SuwilO2uDH88gnAjk=
=pN2C
-----END PGP SIGNATURE-----
--- check_swap.c.orig 2004-08-11 19:00:56.000000000 -0400
+++ check_swap.c 2004-08-11 19:07:03.000000000 -0400
@@ -78,7 +78,11 @@
used_swap += used;
free_swap += free;
if (allswaps) {
- percent = 100 * (((double) used) / ((double) total));
+ if (used > 0 && total > 0){
+ percent = 100 * (((double) used) / ((double) total));
+ } else {
+ percent = 0;
+ }
if (percent >= crit_percent || free <= crit_size)
result = max_state (STATE_CRITICAL, result);
else if (percent >= warn_percent || free <= warn_size)
@@ -88,7 +92,11 @@
}
}
}
- percent_used = 100 * (((double) used_swap) / ((double) total_swap));
+ if (used_swap > 0 && total_swap > 0){
+ percent_used = 100 * (((double) used_swap) / ((double) total_swap));
+ } else {
+ percent_used = 0;
+ }
if (percent_used >= crit_percent || free_swap <= crit_size)
result = max_state (STATE_CRITICAL, result);
else if (percent_used >= warn_percent || free_swap <= warn_size)
@@ -132,7 +1