mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-11 22:38:42 +00:00
fix cpu usage bugs
This commit is contained in:
parent
5b52a92d38
commit
9078fe6f65
|
|
@ -113,7 +113,7 @@ final class SystemUtils
|
||||||
if (\stristr(\PHP_OS, 'WIN') !== false) {
|
if (\stristr(\PHP_OS, 'WIN') !== false) {
|
||||||
$cpuUsage = null;
|
$cpuUsage = null;
|
||||||
\exec('wmic cpu get LoadPercentage', $cpuUsage);
|
\exec('wmic cpu get LoadPercentage', $cpuUsage);
|
||||||
$cpuUsage = (int) ($cpuUsage[1] ?? 0);
|
$cpuUsage = (int) ($cpuUsage[1] ?? -1);
|
||||||
} elseif (\stristr(\PHP_OS, 'LINUX') !== false) {
|
} elseif (\stristr(\PHP_OS, 'LINUX') !== false) {
|
||||||
$loadavg = \sys_getloadavg();
|
$loadavg = \sys_getloadavg();
|
||||||
|
|
||||||
|
|
@ -123,7 +123,7 @@ final class SystemUtils
|
||||||
|
|
||||||
$nproc = (int) \exec('nproc');
|
$nproc = (int) \exec('nproc');
|
||||||
if ($nproc === 0) {
|
if ($nproc === 0) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cpuUsage = $loadavg[0] * 100 / $nproc;
|
$cpuUsage = $loadavg[0] * 100 / $nproc;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user