mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Fix Linux OS bugs
This commit is contained in:
parent
cdf6089e0b
commit
e1a16a26c2
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user