mirror of
https://github.com/ShaYmez/ezservermonitor-web.git
synced 2026-06-01 21:45:03 -04:00
CPU : changes on retrieving CPU information
Load Average and CPU : fix on recovery the number of CPU cores Last login : the datas are retrieved differently
This commit is contained in:
@@ -2,24 +2,24 @@
|
||||
|
||||
class Misc
|
||||
{
|
||||
/**
|
||||
* Returns human size
|
||||
*/
|
||||
/**
|
||||
* Returns human size
|
||||
*/
|
||||
public static function getSize($filesize, $precision = 2)
|
||||
{
|
||||
$units = array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y');
|
||||
|
||||
|
||||
foreach ($units as $idUnit => $unit)
|
||||
{
|
||||
if ($filesize > 1024)
|
||||
$filesize /= 1024;
|
||||
$filesize /= 1024;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return round($filesize, $precision).' '.$units[$idUnit].'B';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns hostname
|
||||
@@ -30,6 +30,26 @@ class Misc
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns CPU cores number
|
||||
*/
|
||||
public static function getCpuCoresNumber()
|
||||
{
|
||||
if (!($num_cores = shell_exec('/bin/grep -c ^processor /proc/cpuinfo')))
|
||||
{
|
||||
if (!($num_cores = trim(shell_exec('/usr/bin/nproc'))))
|
||||
{
|
||||
$num_cores = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((int)$num_cores <= 0)
|
||||
$num_cores = 1;
|
||||
|
||||
return (int)$num_cores;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns server IP
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user