1 頁 (共 1 頁)

Apache-top

發表於 : 2010-02-05 16:01:31
yehlu
http://portable.easylife.tw/2003

通常我們在管理Linux系統的時候,top的指令是不能缺少的,就像我們在Windows習慣有工作管理員一樣,之前也曾介紹過比top還更好用的htop,這些即時可以得知系統狀況的指令的確會是好幫手,最近手頭上的機器一直忙到翻掉,很明確的就是Apache出了問題,那該如何知道Apache在忙些什麼?這時候不如就試試看Apache top工具。

之前有mrtg去監控 apache process的執行數量,首先開啟apache server-status的功能,讓我們可以透過瀏覽器或是本機讀取http://localhost/server-status,或是在本機執行 service httpd fullstatus都可以看到apache最新的狀態,不過這個狀態是很簡單的一種文字模式,要一直不斷讀取才可以一直看到最即時的。

為了要能像top一樣觀察,我找了apache-top的工具,希望可以找出吃資源的兇手,apache-top.py是單一的執行檔,只要系統內能夠用行python就能夠執行,下載回家之後記得chmod +x apache-top.py,之後就可以使用囉!

apache-top.py -u http://127.0.0.1/server-status
執行過後就像最上方的圖片一樣囉!

使用方式:
Usage: apache-top -u url
-u url Url where apache-status is located
Example: apache-top.py -u http://www.domain.com/server-status

可以依照不同欄位進行排序,我想C和I應該都會很實用。
Interactive keys:
q Exit
P Sort by PID
C Sort by CPU usage
S Sort by Seconds since beginning of most recent request
V Sort by VirtualHost
M Sort by Mopde of operation
R Sort by Request
I Sort by Ip
a Switch between show all processes and show only active processes (default)
r Reverse sort

若你同樣有管理apache的需求,可以試試看唷^^

apache-top
http://www.fr3nd.net/projects/apache-top/

Re: Apache-top

發表於 : 2010-02-05 16:04:06
yehlu
mv /etc/apache2/mods-available/status* /etc/apache2/mods-enabled/

<IfModule mod_status.c>
#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Uncomment and change the ".example.com" to allow
# access from other hosts.
#
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost ip6-localhost
# Allow from .example.com
</Location>

</IfModule>