<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[Linux中Nginx的实时监控]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Unix/LinuxC技术]]></category>
<pubDate>Thu, 31 Mar 2016 03:53:17 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景:现在流行nginx，于是安装一个监控可能没有必要，但是机器多可能还是有必要装一个agent之类的，这种小工具一般有个三五台服务器可以用用，大型的还得自己搞一套体系才行。<br/><br/>场景<br/><br/>想查看Nginx的实时状态信息，如哪些请求最频繁、哪些IP访问次数多 ……<br/><br/>例如服务器出现带宽持续很高，就需要看下现在哪些请求的流量大<br/><br/>ngxtop<br/><br/>ngxtop就是用来满足这些实时监控需求的，是个非常小巧实用的工具<br/><br/>ngxtop通过分析nginx的访问日志，使用类似top命令的界面实时展示出来<br/><br/>需要注意的是，ngxtop是查看实时状态信息，就是在执行ngxtop命令之后的统计信息，和top一样，不要理解为是对所有日志内容的统计<br/><br/>基本用法<br/><br/>$ ngxtop<br/><br/>结果形式如下<br/><br/>显示大图<br/><br/><br/>实用案例<br/><br/>查看404状态的请求<br/><br/>$ ngxtop top request_path --filter &#039;status == 404&#039;<br/><br/>查看响应流量最高的请求<br/><br/>$ ngxtop --order-by &#039;avg(bytes_sent) * count&#039;<br/><br/>查看访问量最大的IP<br/><br/>$ ngxtop --group-by remote_addr<br/><br/>查看状态为4xx或者5xx的请求，同时显示status和http_referer信息<br/><br/>$ ngxtop -i &#039;status &gt;= 400&#039; print request status http_referer<br/><br/>查看以某字符串开头的请求<br/><br/>ngxtop --filter &#039;request_path.startswith(&quot;/wp&quot;)&#039;<br/><br/>参数说明<br/><br/>-l: 指定日志文件的完整路径，默认情况下会读取nginx.conf里指定的访问日志路径<br/><br/>-f: 日志格式<br/><br/>-t : 更新频率，默认2秒<br/><br/>-g: 根据变量 group by，默认变量是 request_path<br/><br/>-o: 根据变量 order by，默认变量是 count<br/><br/>-h: help，详细的命令参数说明和使用方法，可以用这个参数查看帮助<br/><br/>内置变量<br/><br/>可以对以下内置变量进行操作，例如上面案例中的&#039;status &gt;= 400&#039;<br/><br/>bodybytessend<br/><br/>http_referer<br/><br/>httpuseragent<br/><br/>remote_addr<br/><br/>remote_user<br/><br/>request<br/><br/>status<br/><br/>time_local<br/><br/>安装<br/><br/>ngxtop的安装需要依赖库 pip<br/><br/>然后使用pip安装 ngxtop<br/><br/>$ sudo pip install ngxtop
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] Linux中Nginx的实时监控]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>