summaryrefslogtreecommitdiff
path: root/libs/memory.php
diff options
context:
space:
mode:
authorShevAbam <shevabam@gmail.com>2014-06-18 10:11:11 +0200
committerShevAbam <shevabam@gmail.com>2014-06-18 10:11:11 +0200
commit20705a550df5b13a544dc0865c6aef16e64c99d9 (patch)
treee396dface41e30d39a68d5fe66097b1f8f641a81 /libs/memory.php
+ First commit (version 2.0)v2.0
Diffstat (limited to 'libs/memory.php')
-rw-r--r--libs/memory.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/libs/memory.php b/libs/memory.php
new file mode 100644
index 0000000..27a783e
--- /dev/null
+++ b/libs/memory.php
@@ -0,0 +1,30 @@
+<?php
+require 'Utils/Misc.class.php';
+
+// Free
+if (!($free = shell_exec('grep MemFree /proc/meminfo | awk \'{print $2}\'')))
+{
+ $free = 0;
+}
+
+// Total
+if (!($total = shell_exec('grep MemTotal /proc/meminfo | awk \'{print $2}\'')))
+{
+ $total = 0;
+}
+
+// Used
+$used = $total - $free;
+
+// Percent used
+$percent_used = 100 - (round($free / $total * 100));
+
+
+$datas = array(
+ 'used' => Misc::getSize($used * 1024),
+ 'free' => Misc::getSize($free * 1024),
+ 'total' => Misc::getSize($total * 1024),
+ 'percent_used' => $percent_used,
+);
+
+echo json_encode($datas); \ No newline at end of file