From 2f5a403fc4a54ecefbb7f832bef7900a08c24baf Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 8 Feb 2022 10:04:19 -0500 Subject: [PATCH] Handle when no swap is configured --- web/skins/classic/includes/functions.php | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index beb6590e0..6055a5805 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -472,19 +472,21 @@ function getRamHTML() { } else if ($mem_used_percent > 90) { $used_class = 'text-warning'; } - $swap_used = $meminfo['SwapTotal'] - $meminfo['SwapFree']; - $swap_used_percent = (int)(100*$swap_used/$meminfo['SwapTotal']); - $swap_class = ''; - if ($swap_used_percent > 95) { - $swap_class = 'text-danger'; - } else if ($swap_used_percent > 90) { - $swap_class = 'text-warning'; - } - $result .= ' '.PHP_EOL; + ''.translate('Memory').': '.$mem_used_percent.'% '; + + if ($meminfo['SwapTotal']) { + $swap_used = $meminfo['SwapTotal'] - $meminfo['SwapFree']; + $swap_used_percent = (int)(100*$swap_used/$meminfo['SwapTotal']); + $swap_class = ''; + if ($swap_used_percent > 95) { + $swap_class = 'text-danger'; + } else if ($swap_used_percent > 90) { + $swap_class = 'text-warning'; + } + $result .= ''.translate('Swap').': '.$swap_used_percent.'% '; + } # end if SwapTotal + $result .= ''.PHP_EOL; return $result; }