mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-06-09 08:42:17 -04:00
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
This commit is contained in:
parent
2f904659dc
commit
49b7afb027
1 changed files with 7 additions and 1 deletions
|
|
@ -310,7 +310,13 @@ main (int argc, char **argv)
|
|||
# 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),
|
||||
|
|
|
|||
Loading…
Reference in a new issue