Skip to content

Commit

Permalink
Fix the bug that undefined swoole_cpu_num() on swow (#5355)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia authored Feb 4, 2023
1 parent 7d0f2aa commit ae00a93
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Listener/OnMetricFactoryReady.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Hyperf\Metric\MetricFactoryPicker;
use Hyperf\Metric\MetricSetter;
use Hyperf\Utils\Coroutine;
use Hyperf\Utils\System;
use Psr\Container\ContainerInterface;
use Swoole\Server as SwooleServer;

Expand Down Expand Up @@ -112,7 +113,7 @@ public function process(object $event): void
}

$load = sys_getloadavg();
$metrics['sys_load']->set(round($load[0] / swoole_cpu_num(), 2));
$metrics['sys_load']->set(round($load[0] / System::getCpuCoresNum(), 2));
$metrics['metric_process_memory_usage']->set(memory_get_usage());
$metrics['metric_process_memory_peak_usage']->set(memory_get_peak_usage());
});
Expand Down

0 comments on commit ae00a93

Please sign in to comment.