小知识:采用ngxtop实现nginx实时访问数据统计

对于nginx的实时访问数据统计可采用ngxtop实现监控web server的访问情况 。ngxtop 允许你对 NGINX 的访问日志 (access log) 进行实时解析, 并输出类似 top 的有用信息。

ngxtop 是 python 脚本安装包,需要python支持。

对于python的包和库文件我们一般喜欢pip管理,没有安装的可以:

1wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
2python get-pip.py #安装pip python包管理工具
3pip install ngxtop #下载安装ngxtop

使用:

1ngxtop -l /usr/local/nginx/logs/access.log

显示请求最多的ip和request

1ngxtop -t 1 -l /var/log/nginx/access.log top remote_addr request

使用帮助:

01Usage:
02ngxtop [options]
03ngxtop [options] (print|top|avg|sum) <var>
04ngxtop info
05
06Options:
07-l <file>, –access-log <file> access log file to parse.
08-f <format>, –log-format <format> log format as specify in log_format directive.
09–no-follow ngxtop default behavior is to ignore current lines in log
10and only watch for new lines as they are written to the access log.
11Use this flag to tell ngxtop to process the current content of the access log instead.
12-t <seconds>, –interval <seconds> report interval when running in follow mode [default: 2.0]
13-g <var>, –group-by <var> group by variable [default: request_path]
14-w <var>, –having <expr> having clause [default: 1]
15-o <var>, –order-by <var> order of output for default query [default: count]
16-n <number>, –limit <number> limit the number of records included in report for top command [default: 10]
17-a <exp> …, –a <exp> … add exp (must be aggregation exp: sum, avg, min, max, etc.) into output
18-v, –verbose more verbose output
19-d, –debug print every line and parsed record
20-h, –help print this help message.
21–version print version information.
22Advanced / experimental options:
23-c <file>, –config <file> allow ngxtop to parse nginx config file for log format and location.
24-i <filter-expression>, –filter <filter-expression> filter in, records satisfied given expression are processed.
25-p <filter-expression>, –pre-filter <filter-expression> in-filter expression to check in pre-parsing phase.
声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:Linux服务器搭建nvidia-docker环境过程详解

2023-5-9 2:44:46

建站知识

小知识:详解Linux动态库生成与使用指南

2023-5-9 2:53:12

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索