diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index b25f3f5e5..b346f9460 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -265,7 +265,8 @@ function getNormalNavBarHTML($running, $user, $bandwidth_options, $view, $skin) echo getSysLoadHTML(); echo getDbConHTML(); echo getStorageHTML(); - echo getShmHTML(); + echo getRamHTML(); + #echo getShmHTML(); #echo getLogIconHTML(); ?> @@ -323,7 +324,8 @@ function getCollapsedNavBarHTML($running, $user, $bandwidth_options, $view, $ski echo getSysLoadHTML(); echo getDbConHTML(); echo getStorageHTML(); - echo getShmHTML(); + echo getRamHTML(); + #echo getShmHTML(); echo getLogIconHTML(); ?> @@ -456,6 +458,37 @@ function getStorageHTML() { return $result; } +function getRamHTML() { + $result = ''; + if ( !canView('System') ) return $result; + $contents = file_get_contents('/proc/meminfo'); + preg_match_all('/(\w+):\s+(\d+)\s/', $contents, $matches); + $meminfo = array_combine($matches[1], $matches[2]); + $mem_used = $meminfo['MemTotal'] - $meminfo['MemFree'] - $meminfo['Buffers'] - $meminfo['Cached']; + $mem_used_percent = (int)(100*$mem_used/$meminfo['MemTotal']); + $used_class = ''; + if ($mem_used_percent > 95) { + $used_class = 'text-danger'; + } 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; + + return $result; +} + // Returns the html representing the current capacity of mapped memory filesystem (usually /dev/shm) function getShmHTML() { $result = '';