diff options
author | Björn Schießle <bjoern@schiessle.org> | 2016-12-22 16:25:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 16:25:26 +0300 |
commit | ef255d7350586801b0d3fb028baacfc553d10b68 (patch) | |
tree | f100ec553edb7f3c5267231dee5d3b13e0e6e972 /lib | |
parent | 6025651988914b06e9815c2ecbb0f398bae1e11a (diff) | |
parent | d133a4d69a127337c6de2b79815d209d20ce104d (diff) |
Merge branch 'master' into web-ui
Diffstat (limited to 'lib')
-rw-r--r-- | lib/DatabaseStatistics.php | 2 | ||||
-rw-r--r-- | lib/Settings/AdminSection.php | 2 | ||||
-rw-r--r-- | lib/SystemStatistics.php | 15 |
3 files changed, 13 insertions, 6 deletions
diff --git a/lib/DatabaseStatistics.php b/lib/DatabaseStatistics.php index 50abfa8..a604a34 100644 --- a/lib/DatabaseStatistics.php +++ b/lib/DatabaseStatistics.php @@ -93,7 +93,7 @@ class DatabaseStatistics { switch ($this->config->getSystemValue('dbtype')) { case 'mysql': $db_name = $this->config->getSystemValue('dbname'); - $sql = 'SHOW TABLE STATUS FROM ' . $db_name; + $sql = 'SHOW TABLE STATUS FROM `' . $db_name . '`'; $result = $this->connection->executeQuery($sql); $database_size = 0; while ($row = $result->fetch()) { diff --git a/lib/Settings/AdminSection.php b/lib/Settings/AdminSection.php index eb9abea..26e793b 100644 --- a/lib/Settings/AdminSection.php +++ b/lib/Settings/AdminSection.php @@ -51,7 +51,7 @@ class AdminSection implements ISection { * @return string */ public function getName() { - return $this->l->t('Server info'); + return $this->l->t('Monitoring'); } /** diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php index e879d3c..dd483a5 100644 --- a/lib/SystemStatistics.php +++ b/lib/SystemStatistics.php @@ -68,8 +68,8 @@ class SystemStatistics { * @return array with the two values 'mem_free' and 'mem_total' */ protected function getMemoryUsage() { - $memoryUsage = shell_exec('awk -F" " \'{ print $1 $2 }\' /proc/meminfo'); - if ($memoryUsage === null) { + $memoryUsage = @file_get_contents('/proc/meminfo'); + if ($memoryUsage === false) { return ['mem_free' => 'N/A', 'mem_total' => 'N/A']; } $array = explode(PHP_EOL, $memoryUsage); @@ -77,12 +77,19 @@ class SystemStatistics { $values = array_slice($array, 0, count($array) - 1); $data = []; foreach($values as $value) { - list($k, $v) = explode(':', $value); + list($k, $v) = preg_split('/[\s:]+/', $value); $data[$k] = $v; } + if (array_key_exists('MemAvailable', $data)) { + // MemAvailable is only present in newer kernels (after 2014). + $available = $data['MemAvailable']; + } else { + $available = $data['MemFree']; + } + return [ - 'mem_free' => (int)$data['MemAvailable'] + (int)$data['SwapFree'], + 'mem_free' => (int)$available + (int)$data['SwapFree'], 'mem_total' => (int)$data['MemTotal'] + (int)$data['SwapTotal'] ]; } |