2014-06-18 04:11:11 -04:00
|
|
|
<?php
|
|
|
|
require 'Utils/Misc.class.php';
|
|
|
|
|
|
|
|
// Free
|
2014-06-18 04:15:18 -04:00
|
|
|
if (!($free = shell_exec('/usr/bin/free -to | grep Mem: | awk \'{print $4+$6+$7}\'')))
|
2014-06-18 04:11:11 -04:00
|
|
|
{
|
|
|
|
$free = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Total
|
2014-06-18 04:15:18 -04:00
|
|
|
if (!($total = shell_exec('/usr/bin/free -to | grep Mem: | awk \'{print $2}\'')))
|
2014-06-18 04:11:11 -04:00
|
|
|
{
|
|
|
|
$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);
|