原创!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. SpringBoot 的拦截器

    首先注册我们要有完整的一个可以开始的开发环境 先自己创建一个配置类 InterceptorConfig, 实现springboot自带的拦截器接口 WebMvcConfigurer. package ...

  2. 各种实用的 PHP 开源库推荐【转】

    转自: https://my.oschina.net/editorial-story/blog/882780 PHP 是一种通用开源脚本语言.语法吸收了 C 语言.Java 和 Perl 的特点,利于 ...

  3. LeetCode 537. 复数乘法(Complex Number Multiplication)

    537. 复数乘法 537. Complex Number Multiplication 题目描述 Given two strings representing two complex numbers ...

  4. Linux中buff/cache内存占用过高解决办法

    在Linux系统中,我们经常用free命令来查看系统内存的使用状态.在一个centos7的系统上,free命令的显示内容大概是这样一个状态: 这个命令几乎是每一个使用过Linux的人必会的命令,但越是 ...

  5. adb常用命令总结

    针对移动端 Android 的测试, adb 命令是很重要的一个点,必须将常用的 adb 命令熟记于心, 将会为 Android 测试带来很大的方便,其中很多命令将会用于自动化测试的脚本当中. And ...

  6. 转载:c++获取本机IP地址

    windows下获取IP地址的两种方法: 一种可以获取IPv4和IPv6,但是需要WSAStartup: 一种只能取到IPv4,但是不需要WSAStartup: 如下: 方法一:(可以获取IPv4和I ...

  7. Hadoop2.8.4集群配置

    建hadoop用户 #添加用户hadoop adduser hadoop 这个过程中需要输入密码两次 Enter new password: Retype new password: passwd: ...

  8. SQL Server中,常用的全局变量

    在SQL Server中,全局变量是一种特殊类型的变量,服务器将维护这些变量的值.全局变量以@@前缀开头,不必进行声明,它们属于系统定义的函数.下表就是SQL Server中一些常用的全局变量. 全局 ...

  9. 2.8_Database Interface ADO由来

    OLE-DB,它无法广为流行,因为如下两点: 1.由于OLE-DB太底层化,使用上非常复杂,需要程序员拥有高潮的技巧. 2.OLEDB标准的API是C++API,只能供C++语言调用. 为了使得流行的 ...

  10. CarbonCopyCloner 硬盘对拷

    CarbonCopyCloner 硬盘对拷 建议使用 5.1.14-b1以上的版本. 安装文件包 CarbonCopyCloner-5.1.14-b1.dmg ================== E ...