aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_swap.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2004-03-02 05:01:19 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2004-03-02 05:01:19 +0000
commitc06a4680946c6be0f19342dfd2737bebee8690bd (patch)
treecf566ce6d1592df092bde3a5966f582dff2600e7 /plugins/check_swap.c
parent3c81964713e4114d7f40f95e9373c24b596d1efd (diff)
downloadmonitoring-plugins-c06a4680946c6be0f19342dfd2737bebee8690bd.tar.gz
fix div by zero error when swaptotal is zero (Flo Gleixner)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@834 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r--plugins/check_swap.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index fe792e87..1155ed0e 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -73,8 +73,8 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- status = strdup("");
- perf = strdup("");
+ status = strdup ("");
+ perf = strdup ("");
if (process_arguments (argc, argv) != OK)
usage (_("Invalid command arguments supplied\n"));
@@ -90,7 +90,10 @@ main (int argc, char **argv)
used_swap += dskused;
free_swap += dskfree;
if (allswaps) {
- percent = 100 * (((double) dskused) / ((double) dsktotal));
+ if (dsktotal == 0)
+ percent=100.0;
+ else
+ percent = 100 * (((double) dskused) / ((double) dsktotal));
result = max_state (result, check_swap (percent, dskfree));
if (verbose)
asprintf (&status, "%s [%llu (%d%%)]", status, dskfree, 100 - percent);