BUG: https://bugzilla.samba.org/show_bug.cgi?id=12362
Don't do a percentage calculation for either memtotal or swaptotal if they
are zero.
Signed-off-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit
bf3f22315a281fb44a5cd9b075b7915138145d6e)
$1 == "SwapTotal:" { swaptotal = $2 }
END {
if (memavail != 0) { memfree = memavail ; }
- print int((memtotal - memfree) / memtotal * 100),
- int((swaptotal - swapfree) / swaptotal * 100)
+ if (memtotal != 0) { print int((memtotal - memfree) / memtotal * 100) ; } else { print 0 ; }
+ if (swaptotal != 0) { print int((swaptotal - swapfree) / swaptotal * 100) ; } else { print 0 ; }
}')
_mem_usage="$1"
_swap_usage="$2"