summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShevAbam <shevabam@gmail.com>2015-02-05 18:29:16 +0100
committerShevAbam <shevabam@gmail.com>2015-02-05 18:29:16 +0100
commit086a1829e65a8c148b1f5c4aa6251a29bead3ea6 (patch)
tree633db42727e4a4141651b51d3d7d7ecafa72b94c
parent3ed4c1d633f3ddfc50d921c5d5c19ebf7cf640c4 (diff)
Fixed memory datas on Arch #15
-rw-r--r--index.php4
-rw-r--r--libs/memory.php13
2 files changed, 11 insertions, 6 deletions
diff --git a/index.php b/index.php
index 6220faa..3c34316 100644
--- a/index.php
+++ b/index.php
@@ -245,7 +245,7 @@ $update = $Config->checkUpdate();
<table class="firstBold">
<tbody>
<tr>
- <td class="w20p">Used</td>
+ <td class="w20p">Used %</td>
<td><div class="progressbar-wrap"><div class="progressbar" style="width: 0%;">0%</div></div></td>
</tr>
<tr>
@@ -277,7 +277,7 @@ $update = $Config->checkUpdate();
<table class="firstBold">
<tbody>
<tr>
- <td class="w20p">Used</td>
+ <td class="w20p">Used %</td>
<td><div class="progressbar-wrap"><div class="progressbar" style="width: 0%;">0%</div></div></td>
</tr>
<tr>
diff --git a/libs/memory.php b/libs/memory.php
index 67fee34..81d9ac9 100644
--- a/libs/memory.php
+++ b/libs/memory.php
@@ -1,14 +1,19 @@
<?php
require 'Utils/Misc.class.php';
-// Free
-if (!($free = shell_exec('/usr/bin/free -to | grep Mem: | awk \'{print $4+$6+$7}\'')))
+$free = 0;
+
+if (shell_exec('cat /proc/meminfo'))
{
- $free = 0;
+ $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;
}
// Total
-if (!($total = shell_exec('/usr/bin/free -to | grep Mem: | awk \'{print $2}\'')))
+if (!($total = shell_exec('grep MemTotal /proc/meminfo | awk \'{print $2}\'')))
{
$total = 0;
}