summaryrefslogtreecommitdiff
path: root/libs/memory.php
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2016-08-03 18:17:23 +0200
committerRichard Braun <rbraun@sceen.net>2016-08-03 18:17:23 +0200
commit158db3350522adba33f28bf78e4baad141bc5145 (patch)
tree724b5e448123df426db0c48ef512c0a57a060c77 /libs/memory.php
parentb6d98b7f12b2e484f3c2728a69ae99c759582f82 (diff)
Changes specific to darnassus.sceen.netHEADdarnassus
Diffstat (limited to 'libs/memory.php')
-rw-r--r--libs/memory.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/libs/memory.php b/libs/memory.php
index a4eda7b..d2826f2 100644
--- a/libs/memory.php
+++ b/libs/memory.php
@@ -2,14 +2,13 @@
require '../autoload.php';
$free = 0;
+$cached = 0;
if (shell_exec('cat /proc/meminfo'))
{
$free = shell_exec('grep MemFree /proc/meminfo | awk \'{print $2}\'');
$buffers = shell_exec('grep Buffers /proc/meminfo | awk \'{print $2}\'');
- $cached = shell_exec('grep Cached /proc/meminfo | awk \'{print $2}\'');
-
- $free = (int)$free + (int)$buffers + (int)$cached;
+ $cached = $buffers + shell_exec('grep Cached /proc/meminfo | awk \'{print $2}\'');
}
// Total
@@ -19,19 +18,20 @@ if (!($total = shell_exec('grep MemTotal /proc/meminfo | awk \'{print $2}\'')))
}
// Used
-$used = $total - $free;
+$used = $total - $free - $cached;
// Percent used
$percent_used = 0;
if ($total > 0)
- $percent_used = 100 - (round($free / $total * 100));
+ $percent_used = round($used / $total * 100);
$datas = array(
'used' => Misc::getSize($used * 1024),
'free' => Misc::getSize($free * 1024),
+ 'cached ' => Misc::getSize($cached * 1024),
'total' => Misc::getSize($total * 1024),
'percent_used' => $percent_used,
);
-echo json_encode($datas); \ No newline at end of file
+echo json_encode($datas);