原创!ngxtop-监控nginx的利器!!!


无论名称还是界面,ngxtop的灵感均源自大名鼎鼎的top命令.ngxtop的功能就是,分析Nginx访问日志文件(以及其他日志文件,比如Apache2日志),

并通过类似top的界面,实时显示分析后所得的结果.你可能吹嘘自己的综合监控工具拥有各种各样的所需功能,但说到简洁性,肯定比不过ngxtop,而简洁性是不可忽视的一大优点.

1. 先安装pip

网址: https://pypi.python.org/packages/source/p/pip/

例如: wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz --no-check-certificate # 由于下载pip是基于https协议的,故需要在wget url后面加上--no-check-certificate,否则不能下载

tar zxvf pip-1.5.6.tar.gz

cd pip-1.5.6

python setup.py install

2. 安装ngxtop

pip install ngxtop

3.使用方法:

cd ${nginx的安装目录}

ngxtop -c conf/nginx.conf #它会显示由Nginx处理的10个请求,按请求数量排序.想显示前20个最频繁的请求,只要运行这个命令:$ ngxtop -n 20

4. 技巧

#如果你愿意,也可以定制所要显示的变量.为此,只要列出你感兴趣的变量."print"命令会显示一个个请求: ngxtop print request http_user_agent remote_addr

#想显示客户机的最常出现的IP地址,只要运行这个命令:ngxtop top remote_addr

#想显示状态代码是404的请求,只要运行这个命令:ngxtop -i 'status == 404' print request status

#除了Nginx外,ngxtop还能够处理其他日志文件,比如Apache访问日志.想监控Apache Web服务器,只要使用这个命令: tail -f /var/log/apache2/access.log | ngxtop -f common

5.附录:

Usage:

ngxtop [options]

ngxtop [options] (print|top|avg|sum) <var>

ngxtop info

Options:

-l <file>, --access-log <file> access log file to parse.

-f <format>, --log-format <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 <seconds>, --interval <seconds> report interval when running in follow mode [default: 2.0]

-g <var>, --group-by <var> group by variable [default: request_path]

-w <var>, --having <expr> having clause [default: 1]

-o <var>, --order-by <var> order of output for default query [default: count]

-n <number>, --limit <number> limit the number of records included in report for top command [default: 10]

-a <exp> ..., --a <exp> ... 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 <file>, --config <file> allow ngxtop to parse nginx config file for log format and location.

-i <filter-expression>, --filter <filter-expression> filter in, records satisfied given expression are processed.

-p <filter-expression>, --pre-filter <filter-expression> in-filter expression to check in pre-parsing phase.


原创!ngxtop-监控nginx的利器!!!的更多相关文章

  1. ngxtop:在命令行实时监控 Nginx 的神器

    Nginx网站服务器在生产环境中运行的时候需要进行实时监控.实际上,诸如Nagios, Zabbix, Munin 的网络监控软件是支持 Nginx 监控的. 如果你不需要以上软件提供的综合性报告或者 ...

  2. 使用ngxtop实时监控nginx

    Ngxtop实时解析nginx访问日志,并且将处理结果输出到终端,功能类似于系统命令top,所以这个软件起名ngxtop.有了ngxtop,你可以实时了解到当前nginx的访问状况,再也不需要tail ...

  3. ngxtop实时监控nginx状态

    ngxtop实时解析nginx访问日志,并且将处理结果输出到终端,功能类似于系统命令top,所以这个软件起名ngxtop.有了ngxtop,你可以实时了解到当前nginx的访问状况,再也不需要tail ...

  4. 如何监控 Nginx?

    什么是 Nginx? Nginx("engine-x")是一个 HTTP 和反向代理服务器,同时也是一个邮件代理服务器和通用的 TCP 代理服务器.作为一个免费开源的服务器,Ngi ...

  5. ngxtop(nginx实时监控工具)

    原文内容来自于LZ(楼主)的印象笔记,如出现排版异常或图片丢失等问题,可查看当前链接:https://app.yinxiang.com/shard/s17/nl/19391737/dea1ca3a-7 ...

  6. 一个小工具帮你搞定实时监控Nginx服务器

    Linux运维工程师的首要职责就是保证业务7 x 24小时稳定的运行,监控Web服务器对于查看网站上发生的情况至关重要.关注最多的便是日志变动,查看实时日志文件变动大家第一反应应该是'tail -f ...

  7. 使用Zabbix监控Nginx服务实战案例

    使用Zabbix监控Nginx服务实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.编译安装nginx步骤详解并开启状态页 博主推荐阅读: https://www.cn ...

  8. Zabbix 监控 Nginx(四)

    简介: 如何使用 Zabbix 监控 Nginx 状态 ? 1.获取 Nginx 状态( HTTP Stub Status ) [root@localhost ~]# /apps/product/ng ...

  9. Python 监控nginx服务是否正常

    Python 监控nginx服务是否正常 #!/usr/bin/env python import os, sys, time from time import strftime while True ...

随机推荐

  1. JSVC安装

    执行./start-all.sh启动hadoop时报错 Starting datanodes node1: ERROR: Cannot set priority of datanode process ...

  2. 贴一个markdown语法,mweb自带的说明

    Markdown 语法和 MWeb 写作使用说明 Markdown 的设计哲学 Markdown 的目標是實現「易讀易寫」.不過最需要強調的便是它的可讀性.一份使用 Markdown 格式撰寫的文件應 ...

  3. new Image 读取宽高为0——onload

    获取图片一张图片的大小 let img = new Image() img.src = imgUrl if ( img.width != 375 || img.height != 200 ) { me ...

  4. ③ Python3.0 数字类型

    Python3 的六个标准数据类型中:不可变数据(3 个):Number(数字).String(字符串).Tuple(元组):可变数据(3 个):List(列表).Dictionary(字典).Set ...

  5. Postman请求后台报错:Invalid character found in method name. HTTP method names must be tokens

    在使用Postman请求后台时Postman出现 开发工具控制台报 信息: Error parsing HTTP request header Note: further occurrences of ...

  6. 【阿里云开发】- 安装tomcat

    Tomcat配置过程 1.下载Tomcat 官网地址:http://tomcat.apache.org/ 这里我用的是apache-tomcat-8.5.38.tar.gz 2.通过ftp工具将下载好 ...

  7. Coldfusion Sql查询分组输出

    <cfoutput query="myQry" group="date"> #date# <cfoutput> #detail# < ...

  8. 1+X证书学习日志——定位

    ## 静态定位:                 position:static;    默认值,指定left/right/top/bottom/  没有作用.                 pos ...

  9. 6.transform?animation?区别?animation-duration【CSS】

    1.Transform:它和width.left一样,定义了元素很多静态样式实现变形.旋转.缩放.移位及透视等功能,通过一系列功能的组合我们可以实现很炫酷的静态效果(非动画).  2.Animatio ...

  10. Spring Cloud原理详解

    概述 毫无疑问,Spring Cloud是目前微服务架构领域的翘楚,无数的书籍博客都在讲解这个技术.不过大多数讲解还停留在对Spring Cloud功能使用的层面,其底层的很多原理,很多人可能并不知晓 ...