如何在Ubuntu中使用mod_status監控Apache性能

雖然你能夠隨時偷看Apache的日誌文件來獲取Web服務器的信息,好比活躍的鏈接,但你能夠經過啓用mod_status模塊來獲取Web服務器性能的詳細狀況。
什麼是mod_status模塊?
mod_status模塊是Apache的一個模塊,它容許用戶在一個普通的HTML頁面上訪問關於Apache性能的高度詳細的信息。事實上,Apache維護了本身的服務器狀態頁面,供公衆查看。
您能夠經過如下地址查看Apache(Ubuntu)的狀態:https://apache.org/server-status
如何在Ubuntu中使用mod_status監控Apache性能
Apache的mod_status能夠提供一個包含如下信息的純HTML頁面。
服務器版本
當前日期和時間爲UTC
服務器正常運行時間
服務器負載
總流量
收到的請求總數
網絡服務器的CPU使用率
與各自客戶的PID等等。
如今讓咱們看看如何得到有關Apache Web服務器的最新統計數據。
一、測試環境
操做系統:Ubuntu 20.04 Ubuntu 20.04
應用程序:Apache HTTP服務器
版本:2.4.41
文檔根目錄: /var/www/html
二、在Apache Ubuntu中啓用mod_status
默認狀況下,Apache的mod_status模塊已經啓用。你能夠經過運行ls命令檢查mods_enabled目錄來驗證,以下所示。
$ ls /etc/apache2/mods-enabled
如何在Ubuntu中使用mod_status監控Apache性能
確保 status.conf 和 status.load 文件存在。若是不存在,你須要經過調用命令來啓用mod_status模塊。
$ sudo /usr/sbin/a2enmod status
三、在Apache Ubuntu中配置mod_status
如前所述,mod_status已經被啓用。然而,要訪問服務器狀態頁面還須要額外的調整。要作到這一點,你須要修改status.conf 文件。
$ sudo vim /etc/apache2/mods-enabled/status.conf
設置Require ip指令,以反映你將訪問服務器的機器的IP地址。
如何在Ubuntu中使用mod_status監控Apache性能
保存更改並從新啓動Apache,確認狀態如圖所示。
$ sudo systemctl restart apache2
而後驗證Apache的狀態,確保它能正常運行。
$ sudo systemctl status apache2
如何在Ubuntu中使用mod_status監控Apache性能
此後,瀏覽Web服務器的URL,以下所示。
http://server-ip/server-status
你會看到一個狀態HTML頁面,顯示Apache的主機信息和一系列的統計數據,如圖所示。
如何在Ubuntu中使用mod_status監控Apache性能
注意:若是要讓頁面在每個給定的時間間隔後刷新,例如,5秒,請在URL的結尾添加「?refresh=5」。
http://server-ip/server-status?refresh=5
這比前面的純靜態HTML頁面提供了更好的服務器性能監控能力,關於mod_status模塊的介紹就到這裏了。A5互聯https://www.a5idc.net/html

相關文章
相關標籤/搜索