blob: 67fee34cc3e40b3e02a8059f05ad5e43c621776e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
require 'Utils/Misc.class.php';
// Free
if (!($free = shell_exec('/usr/bin/free -to | grep Mem: | awk \'{print $4+$6+$7}\'')))
{
$free = 0;
}
// Total
if (!($total = shell_exec('/usr/bin/free -to | grep Mem: | 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);
|