采用ngxtop實(shí)現(xiàn)nginx實(shí)時(shí)訪問(wèn)數(shù)據(jù)統(tǒng)計(jì)
對(duì)于nginx的實(shí)時(shí)訪問(wèn)數(shù)據(jù)統(tǒng)計(jì)可采用ngxtop實(shí)現(xiàn)監(jiān)控web server的訪問(wèn)情況 。ngxtop 允許你對(duì) NGINX 的訪問(wèn)日志 (access log) 進(jìn)行實(shí)時(shí)解析, 并輸出類似 top 的有用信息。
ngxtop 是 python 腳本安裝包,需要python支持。
對(duì)于python的包和庫(kù)文件我們一般喜歡pip管理,沒(méi)有安裝的可以:
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
顯示請(qǐng)求最多的ip和request
ngxtop -t 1 -l /var/log/nginx/access.log top remote_addr request
使用幫助:
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.
相關(guān)文章
Nginx單IP地址配置多個(gè)SSL證書(shū)的方法示例
這篇文章主要介紹了Nginx單IP地址配置多個(gè)SSL證書(shū)的方法示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-11-11詳解nginx 的 default_server 定義及匹配規(guī)則
這篇文章主要介紹了詳解nginx 的 default_server 定義及匹配規(guī)則,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08Linux Nginx VPS下簡(jiǎn)單解決CC攻擊
Linux Nginx VPS下簡(jiǎn)單解決CC攻擊,使用Nginx與php的朋友可以參考下。2010-12-12LNMPA遇到504 Gateway time-out錯(cuò)誤的解決方法
這篇文章主要介紹了LNMPA遇到504 Gateway time-out錯(cuò)誤的解決方法,需要的朋友可以參考下2017-07-07nginx配置ssl證書(shū)實(shí)現(xiàn)https訪問(wèn)的示例
這篇文章主要介紹了nginx配置ssl證書(shū)實(shí)現(xiàn)https訪問(wèn)的示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-03-03Crontab+Shell做Nginx日志切割腳本實(shí)例代碼
本篇文章主要介紹了Crontab+Shell做Nginx日志切割腳本實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05Centos 6.5 64位中Nginx詳細(xì)安裝部署教程
Nginx是一個(gè)web服務(wù)器也可以用來(lái)做負(fù)載均衡及反向代理使用,目前使用最多的就是負(fù)載均衡,具體簡(jiǎn)介我就不介紹了百度一下有很多,下面直接進(jìn)入安裝步驟,需要的朋友可以參考下2017-08-08