diff options
author | M. Sean Finney <seanius@users.sourceforge.net> | 2005-06-29 01:04:10 +0000 |
---|---|---|
committer | M. Sean Finney <seanius@users.sourceforge.net> | 2005-06-29 01:04:10 +0000 |
commit | 49b7afb02704b8d37b0e863efb2651c5ca1cb70f (patch) | |
tree | 6fd2a4eec3cb72d56b2847ebaa3abeae945ec022 | |
parent | 2f904659dc3179148215f16aad4f9098aef222c5 (diff) | |
download | monitoring-plugins-49b7afb02704b8d37b0e863efb2651c5ca1cb70f.tar.gz |
divide by 0 fix for check_swap
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1196 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | plugins/check_swap.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 8f5ebf8e..c152eee1 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
@@ -310,7 +310,13 @@ main (int argc, char **argv) | |||
310 | # endif /* HAVE_SWAP */ | 310 | # endif /* HAVE_SWAP */ |
311 | #endif /* HAVE_PROC_MEMINFO */ | 311 | #endif /* HAVE_PROC_MEMINFO */ |
312 | 312 | ||
313 | percent_used = 100 * ((double) used_swap) / ((double) total_swap); | 313 | /* if total_swap == 0, let's not divide by 0 */ |
314 | if(total_swap) { | ||
315 | percent_used = 100 * ((double) used_swap) / ((double) total_swap); | ||
316 | } else { | ||
317 | percent_used = 0; | ||
318 | } | ||
319 | |||
314 | result = max_state (result, check_swap (percent_used, free_swap)); | 320 | result = max_state (result, check_swap (percent_used, free_swap)); |
315 | printf (_("SWAP %s - %d%% free (%.0f MB out of %.0f MB) %s|"), | 321 | printf (_("SWAP %s - %d%% free (%.0f MB out of %.0f MB) %s|"), |
316 | state_text (result), | 322 | state_text (result), |