Fix Linux OS bugs

This commit is contained in:
Dennis Eichhorn 2017-04-04 20:16:52 +02:00
parent cdf6089e0b
commit e1a16a26c2
2 changed files with 12 additions and 13 deletions

View File

@ -40,15 +40,14 @@ final class OperatingSystem
*/
public static function getSystem() : int
{
switch (PHP_OS) {
case stristr(PHP_OS, 'DAR'):
return SystemType::OSX;
case stristr(PHP_OS, 'WIN'):
return SystemType::WIN;
case stristr(PHP_OS, 'LINIX'):
return SystemType::LINUX;
default:
return SystemType::UNKNOWN;
}
if(stristr(PHP_OS, 'DAR') !== false) {
return SystemType::OSX;
} elseif(stristr(PHP_OS, 'WIN') !== false) {
return SystemType::WIN;
} elseif(stristr(PHP_OS, 'LINIX') !== false) {
return SystemType::LINUX;
}
return SystemType::UNKNOWN;
}
}

View File

@ -112,11 +112,11 @@ class SystemUtils
{
$cpuusage = 0;
if (stristr(PHP_OS, 'WIN')) {
if (stristr(PHP_OS, 'WIN') !== false) {
exec('wmic cpu get LoadPercentage', $cpuusage);
$cpuusage = $cpuusage[1];
} elseif (stristr(PHP_OS, 'LINUX')) {
$cpuusage = \sys_getloadavg()[0];
} elseif (stristr(PHP_OS, 'LINUX') !== false) {
$cpuusage = \sys_getloadavg()[0] * 100;
}
return (int) $cpuusage;