采用ngxtop實(shí)現(xiàn)nginx實(shí)時(shí)訪問數(shù)據(jù)統(tǒng)計(jì)
對于nginx的實(shí)時(shí)訪問數(shù)據(jù)統(tǒng)計(jì)可采用ngxtop實(shí)現(xiàn)監(jiān)控web server的訪問情況 。ngxtop 允許你對 NGINX 的訪問日志 (access log) 進(jìn)行實(shí)時(shí)解析, 并輸出類似 top 的有用信息。
ngxtop 是 python 腳本安裝包,需要python支持。
對于python的包和庫文件我們一般喜歡pip管理,沒有安裝的可以:
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
顯示請求最多的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配置缺少導(dǎo)致CSS不起作用的問題及解決方法
在Web開發(fā)中,確保樣式表正確加載是前端顯示正常工作的關(guān)鍵,然而,有時(shí)候即使CSS文件的路徑和代碼本身沒有問題,CSS樣式也可能無法正確應(yīng)用,本文將分享一個(gè)常見的問題——Nginx配置缺少導(dǎo)致的CSS不起作用,以及如何解決這個(gè)問題,感興趣的朋友一起看看吧2024-07-07
簡單了解Nginx七層負(fù)載均衡的幾種調(diào)度算法
這篇文章主要介紹了簡單了解Nginx七層負(fù)載均衡的幾種調(diào)度算法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11
503 service unavailable錯(cuò)誤解決方案講解
這篇文章主要介紹了503 service unavailable錯(cuò)誤解決方案講解,本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08
SQL操作Pandas?DataFrame的三種方式示例詳解
這篇文章主要為大家介紹了SQL操作Pandas?DataFrame的三種方式示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08
Nginx服務(wù)器實(shí)現(xiàn)通過ip和user_gent限制訪問的方法分析
這篇文章主要介紹了Nginx服務(wù)器實(shí)現(xiàn)通過ip和user_gent限制訪問的方法,結(jié)合實(shí)例形式分析了Nginx通過限制ip和user_gent限制訪問來過濾DDOS攻擊的相關(guān)操作技巧,需要的朋友可以參考下2019-07-07
詳解如何設(shè)置Nginx實(shí)現(xiàn)內(nèi)外網(wǎng)端口映射
在 Nginx 中實(shí)現(xiàn)內(nèi)外網(wǎng)端口映射是一種常見的做法,本文詳細(xì)介紹如何設(shè)置 Nginx 實(shí)現(xiàn)內(nèi)外網(wǎng)端口映射,有需要的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-10-10

