Commit 46362c09 authored by Franco Fichtner's avatar Franco Fichtner

widgets: fix possible division by zero

(cherry picked from commit 2dde9b7c)
parent 7e94b0e8
...@@ -92,8 +92,12 @@ function system_api_kernel() ...@@ -92,8 +92,12 @@ function system_api_kernel()
$inactiveMem = get_single_sysctl("vm.stats.vm.v_inactive_count"); $inactiveMem = get_single_sysctl("vm.stats.vm.v_inactive_count");
$cachedMem = get_single_sysctl("vm.stats.vm.v_cache_count"); $cachedMem = get_single_sysctl("vm.stats.vm.v_cache_count");
$freeMem = get_single_sysctl("vm.stats.vm.v_free_count"); $freeMem = get_single_sysctl("vm.stats.vm.v_free_count");
$result['memory']['total'] = get_single_sysctl('hw.physmem') ; $result['memory']['total'] = get_single_sysctl('hw.physmem');
$result['memory']['used'] = round(((($totalMem - ($inactiveMem + $cachedMem + $freeMem))) / $totalMem)*$result['memory']['total'], 0); if ($totalMem != 0) {
$result['memory']['used'] = round(((($totalMem - ($inactiveMem + $cachedMem + $freeMem))) / $totalMem)*$result['memory']['total'], 0);
} else {
$result['memory']['used'] = gettext('N/A');
}
return $result; return $result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment