原创!ngxtop-监控nginx的利器!!!
原创!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的利器!!!的更多相关文章
- ngxtop:在命令行实时监控 Nginx 的神器
Nginx网站服务器在生产环境中运行的时候需要进行实时监控.实际上,诸如Nagios, Zabbix, Munin 的网络监控软件是支持 Nginx 监控的. 如果你不需要以上软件提供的综合性报告或者 ...
- 使用ngxtop实时监控nginx
Ngxtop实时解析nginx访问日志,并且将处理结果输出到终端,功能类似于系统命令top,所以这个软件起名ngxtop.有了ngxtop,你可以实时了解到当前nginx的访问状况,再也不需要tail ...
- ngxtop实时监控nginx状态
ngxtop实时解析nginx访问日志,并且将处理结果输出到终端,功能类似于系统命令top,所以这个软件起名ngxtop.有了ngxtop,你可以实时了解到当前nginx的访问状况,再也不需要tail ...
- 如何监控 Nginx?
什么是 Nginx? Nginx("engine-x")是一个 HTTP 和反向代理服务器,同时也是一个邮件代理服务器和通用的 TCP 代理服务器.作为一个免费开源的服务器,Ngi ...
- ngxtop(nginx实时监控工具)
原文内容来自于LZ(楼主)的印象笔记,如出现排版异常或图片丢失等问题,可查看当前链接:https://app.yinxiang.com/shard/s17/nl/19391737/dea1ca3a-7 ...
- 一个小工具帮你搞定实时监控Nginx服务器
Linux运维工程师的首要职责就是保证业务7 x 24小时稳定的运行,监控Web服务器对于查看网站上发生的情况至关重要.关注最多的便是日志变动,查看实时日志文件变动大家第一反应应该是'tail -f ...
- 使用Zabbix监控Nginx服务实战案例
使用Zabbix监控Nginx服务实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.编译安装nginx步骤详解并开启状态页 博主推荐阅读: https://www.cn ...
- Zabbix 监控 Nginx(四)
简介: 如何使用 Zabbix 监控 Nginx 状态 ? 1.获取 Nginx 状态( HTTP Stub Status ) [root@localhost ~]# /apps/product/ng ...
- Python 监控nginx服务是否正常
Python 监控nginx服务是否正常 #!/usr/bin/env python import os, sys, time from time import strftime while True ...
随机推荐
- LeetCode 162. 寻找峰值(Find Peak Element) 29
162. 寻找峰值 162. Find Peak Element 题目描述 峰值元素是指其值大于左右相邻值的元素. 给定一个输入数组 nums,其中 nums[i] ≠ nums[i+1],找到峰值元 ...
- linux-sysbench
sysbench是一个模块化的.跨平台.多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况.关于这个项目的详细介绍请看:http://sysbench.sourceforge.ne ...
- Django——用户认证
Django--用户认证 用户与Authentication(身份验证) Django 用户认证系统处理用户帐号,组,权限以及基于cookie的用户会话. 这个系统一般被称为 auth/auth (认 ...
- 数组中重复的数字(Python)
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019-08-13 22:35 # @Author : daryl # @File : ...
- AX2009取销售订单的税额
直接用以下方法即可: Tax::calcTaxAmount(salesLine.TaxGroup, salesLine.TaxItemGroup, systemDateGet(), salesL ...
- 在 WPF 中获取一个依赖对象的所有依赖项属性
原文:在 WPF 中获取一个依赖对象的所有依赖项属性 本文介绍如何在 WPF 中获取一个依赖对象的所有依赖项属性. 本文内容 通过 WPF 标记获取 通过设计器专用方法获取 通过 WPF 标记获取 p ...
- Flutter Image(图片)
Image是一个用于展示图片的组件.支持 JPEG.PNG.GIF.Animated GIF.WebP.Animated WebP.BMP 和 WBMP 等格式. Image 有许多的静态函数: ne ...
- 了解Django之前
什么是web应用? 通俗地讲,就是通过浏览器访问一个网址,该网站从后台调取数据,然后把相应的界面展示给用户这样的一个过程. 什么是HTTP协议? 即超文本传输协议:规定了客户端与服务端消息传输的格 ...
- LVS简单理解
LVS LVS(Linux Virtual Server)即Linux虚拟服务器 目前LVS已经被集成到Linux内核模块中.该项目在Linux内核中实现了基于IP的数据请求负载均衡调度方案 终端用户 ...
- web.config 研究
一.将配置映射成类 1.配置中增加 <configSections> <section name="appConfiguration" type="Oi ...