我怎么知道 apache 进程在做什么?

Joe*_*nsn 12 linux debian apache-2.2

有时 apache 会发疯,吃掉我所有的内存和交换,但我不知道如何找出导致它的网络应用程序。

ps 给了我这个过程的输出;“不间断睡眠(通常是IO)”

www-data  1526  0.1 78.9 14928852 3191628 ?    D    Oct17   6:45 /usr/sbin/apache2 -k start
Run Code Online (Sandbox Code Playgroud)

我怀疑 Ruby+Redmine,但我想确定

Pri*_*rix 12

确保您已mod_status.so在 apache 模块中加载,然后在 httpd.conf 中查找/添加上述内容:

# Uncomment the following lines to enable mod_status support:
#
ExtendedStatus On

<Location /server-status>
SetHandler server-status

Order Deny,Allow
Deny from all
Allow from YOUR_IP_HERE
</Location>
Run Code Online (Sandbox Code Playgroud)

这将允许您查看 http 服务器中正在使用的所有页面加载域。

要访问它,请使用http://your_ip/server-status并且只有定义的 ipAllow from YOUR_IP_HERE才能查看它。


小智 6

lsof -p 将显示它正在等待的文件句柄。此外, strace -p 和 ltrace -p 可能有助于尝试调试它。