mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 05:58:42 +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
|
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;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user