nginx

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > nginx > nginx实时请求监测

nginx实时请求监测的项目实践

作者:bjzhang75

本文主要介绍了nginx实时请求监测,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

一、ngxtop

1、ngxtop介绍

ngxtop是一个实时命令行工具,可以分析nginx访问日志,以表格形式将http请求的主要指标直观展示。ngxtopnginx的访问请求数据实时动态展示,并支持按字段过滤请求。

2、安装

centos环境安装

# 安装python
yum install epel-release
yum install python-pip
# 安装ngxtop
pip install ngxtop

ubuntu环境安装,测试系统为Ubuntu 24.04.2 LTS

apt upgrade -y
apt install python3
sudo apt install pipx
pipx ensurepath
source ~/.bashrc
pipx install ngxtop

3、参数说明

二 、测试

1、指定配置文件

ngxtop -c /usr/local/nginx/conf/nginx.conf 

2、加过滤条件

ngxtop -c /usr/local/nginx/conf/nginx.conf -i 'status == 200' 

3、解析当前access_log

ngxtop -c /usr/local/nginx/conf/nginx.conf --no-follow 

4、指定分组条件

ngxtop -c /usr/local/nginx/conf/nginx.conf -t 1 -g remote_addr 

5、设置刷新时间为1秒

ngxtop -c /usr/local/nginx/conf/nginx.conf -t 1

6、排序

ngxtop -c /usr/local/nginx/conf/nginx.conf -o count -t 1

7、显示前5个结果

ngxtop -c /usr/local/nginx/conf/nginx.conf -o count -t 1 -n 5 

到此这篇关于nginx实时请求监测的项目实践的文章就介绍到这了,更多相关nginx实时请求监测内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文