mirror of
https://github.com/ShaYmez/ezservermonitor-web.git
synced 2024-12-22 01:20:58 -05:00
9970343fe5
General : responsive design General : reload button now spins when you reload block General : update jQuery plugin Knob to 1.2.11 General : optimizing security (config file esm.config.json is now in the conf/ folder with an htaccess) CPU : retrieves correctly CPU frequency for Raspberry Pi CPU : add CPU temperature (+ option to enable/disable) System : little correction for getting distro name Swap : fix if swap is disabled Services status : adds protocol TCP or UDP for checking service status Services status : new option to hide port number (see show_port in services section)
32 lines
635 B
PHP
32 lines
635 B
PHP
<?php
|
|
require '../autoload.php';
|
|
|
|
// Free
|
|
if (!($free = shell_exec('grep SwapFree /proc/meminfo | awk \'{print $2}\'')))
|
|
{
|
|
$free = 0;
|
|
}
|
|
|
|
// Total
|
|
if (!($total = shell_exec('grep SwapTotal /proc/meminfo | awk \'{print $2}\'')))
|
|
{
|
|
$total = 0;
|
|
}
|
|
|
|
// Used
|
|
$used = $total - $free;
|
|
|
|
// Percent used
|
|
$percent_used = 0;
|
|
if ($total > 0)
|
|
$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); |