问题描述
在php中,如何获取当前可用的apache子代数
(apache记分牌中的status = SERVER_READY
)?
In php, how can I get the number of apache children that are currently available
(status = SERVER_READY
in the apache scoreboard)?
我真的希望我有一种简单的方法可以在php中做到这一点,
I'm really hoping there is a simple way to do this in php that I am missing.
推荐答案
您可以执行ps aux | grep httpd
或ps aux | grep apache
的shell命令并计算输出中的行数.
You could execute a shell command of ps aux | grep httpd
or ps aux | grep apache
and count the number of lines in the output.
exec('ps aux | grep apache', $output);
$processes = count($output);
我不确定状态列中的哪个状态表示已准备好接受连接,但是您可以对此进行过滤以获取准备就绪的进程数.
I'm not sure which status in the status column indicates that it's ready to accept a connection, but you can filter against that to get a count of ready processes.
这篇关于如何在php中免费获取apache儿童数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!