在 CentOS 系統中,您可以通過查看 PHP-FPM 日志或 Apache/Nginx 的訪問日志來獲取并發請求數。以下是幾種方法:
PHP-FPM 日志通常位于 /var/log/php-fpm/
目錄下。您可以使用 grep
和 wc
命令來統計并發請求數。
grep -o 'GET /' /var/log/php-fpm/your_php_fpm_log_file.log | wc -l
將 your_php_fpm_log_file.log
替換為您的 PHP-FPM 日志文件名。
Apache 訪問日志通常位于 /var/log/httpd/access_log
或 /var/log/apache2/access.log
。您可以使用 awk
和 sort
命令來統計并發請求數。
awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -nr
將 /var/log/httpd/access_log
替換為您的 Apache 訪問日志文件路徑。
Nginx 訪問日志通常位于 /var/log/nginx/access.log
。您可以使用 awk
和 sort
命令來統計并發請求數。
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -nr
將 /var/log/nginx/access.log
替換為您的 Nginx 訪問日志文件路徑。
這些命令會顯示每個 IP 地址的請求次數。如果您想查看實時的并發請求數,可以使用 htop
或 atop
等工具。要安裝這些工具,請運行以下命令:
sudo yum install htop
# 或者
sudo yum install atop
然后運行 htop
或 atop
,在相應的界面中找到并發請求數。