summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f90465)
raw | patch | inline | side by side (parent: 2f90465)
author | M. Sean Finney <seanius@users.sourceforge.net> | |
Wed, 29 Jun 2005 01:04:10 +0000 (01:04 +0000) | ||
committer | M. Sean Finney <seanius@users.sourceforge.net> | |
Wed, 29 Jun 2005 01:04:10 +0000 (01:04 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1196 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_swap.c | patch | blob | history |
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 8f5ebf8ee15790c7c2f3e65777e745da8b2c95f0..c152eee1e3e30c7cb5d1f9341c2ff349c4ddf0f1 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
# endif /* HAVE_SWAP */
#endif /* HAVE_PROC_MEMINFO */
- percent_used = 100 * ((double) used_swap) / ((double) total_swap);
+ /* if total_swap == 0, let's not divide by 0 */
+ if(total_swap) {
+ percent_used = 100 * ((double) used_swap) / ((double) total_swap);
+ } else {
+ percent_used = 0;
+ }
+
result = max_state (result, check_swap (percent_used, free_swap));
printf (_("SWAP %s - %d%% free (%.0f MB out of %.0f MB) %s|"),
state_text (result),