栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > 服务器

采用ngxtop实现nginx实时访问数据统计

服务器 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

采用ngxtop实现nginx实时访问数据统计

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

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

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

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

使用:

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

显示请求最多的ip和request

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

使用帮助:

Usage:
  ngxtop [options]
  ngxtop [options] (print|top|avg|sum) 
  ngxtop info

Options:
  -l , --access-log  access log file to parse.
  -f , --log-format  log format as specify in log_format directive.
  --no-follow ngxtop default behavior is to ignore current lines in log
    and only watch for new lines as they are written to the access log.
    Use this flag to tell ngxtop to process the current content of the access log instead.
  -t , --interval  report interval when running in follow mode [default: 2.0]
  -g , --group-by  group by variable [default: request_path]
  -w , --having  having clause [default: 1]
  -o , --order-by  order of output for default query [default: count]
  -n , --limit  limit the number of records included in report for top command [default: 10]
  -a  ..., --a  ... add exp (must be aggregation exp: sum, avg, min, max, etc.) into output
  -v, --verbose more verbose output
  -d, --debug print every line and parsed record
  -h, --help print this help message.
  --version print version information.
  Advanced / experimental options:
  -c , --config  allow ngxtop to parse nginx config file for log format and location.
  -i , --filter  filter in, records satisfied given expression are processed.
  -p , --pre-filter  in-filter expression to check in pre-parsing phase.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/183988.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号