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 public static function getSystem() : int
{ {
switch (PHP_OS) { if(stristr(PHP_OS, 'DAR') !== false) {
case stristr(PHP_OS, 'DAR'): return SystemType::OSX;
return SystemType::OSX; } elseif(stristr(PHP_OS, 'WIN') !== false) {
case stristr(PHP_OS, 'WIN'): return SystemType::WIN;
return SystemType::WIN; } elseif(stristr(PHP_OS, 'LINIX') !== false) {
case stristr(PHP_OS, 'LINIX'): return SystemType::LINUX;
return SystemType::LINUX; }
default:
return SystemType::UNKNOWN; return SystemType::UNKNOWN;
}
} }
} }

View File

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