编程技术分享平台

网站首页 > 技术教程 正文

如何用ngxtop监控nginx访问?(nginx 监听ip)

xnh888 2024-09-11 11:01:10 技术教程 43 ℃ 0 评论

ngxtop是用python开发的一款监控nginx访问日志的工具,

它可以实时动态地查看访问最多的请求。

centos上安装ngxtop

yum install python-pip

pip install ngxtop

用ngxtop -h查看其选项,其中几个选项含义如下:

1)-l 指定访问日志

2) -f 指定日志格式

3) --no-follow 只处理当前已经写入的日志文件,而不是实时处理新增的日志

4) -c 指定nginx.conf路径

5) -n 指定显示行号

内容描述.

ngxtop具体用法

1) $ ngxtop

如果报错: Error: Access log file or format was not set and nginx config file cannot be detected. Perhaps nginx is not in your PATH?

这是因为ngxtop找不到可执行文件nginx,解决办法是

ln -s /usr/local/nginx/sbin/nginx /sbin/nginx

2) $ ngxtop -c /usr/local/nginx/conf/nginx.conf -n 20 //

指定nginx.conf,显示20行,结果如图

3) $ ngxtop -c /usr/local/nginx/conf/nginx.conf print request http_user_agent remote_addr //

使用print打印指定变量

4) $ ssh remote tail -f /var/log/apache2/access.log | ngxtop -f common //

分析远程机器的日志

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表