ngx_lua_reqstatus - 實時統計 nginx 狀態的 lua 拓展
ngx_lua_reqstatus
實時監控 Nginx 域名的 qps, 5xx 個數,響應時長, 其中 ganglia_conf
目錄是 ganglia 監控腳本。
nginx.conf
配置 http {
...
...
lua_shared_dict statics_dict 1M; # 初始化變量
lua_package_path "/etc/nginx/ngx_lua_reqstatus/?.lua"; #路徑
log_by_lua_file "/etc/nginx/ngx_lua_reqstatus/hook.lua"; # 添加此句
server {
listen 80;
server_name justforfun.com;
location /{
...
}
}
# 監控服務
server {
listen 127.0.0.1:6080;
location /{
access_by_lua_file "/etc/nginx/ngx_lua_reqstatus/status.lua";
}
}
}
效果
- 查看 域名
justforfun.com
的qps,5xx個數,平均響應時長:
curl localhost:6080/?domain=justforfun.com
- 輸出
Server Name key: justforfun.com Seconds SinceLast: 26.601999998093 Average Req Time Sec: 0.031799983978271 Request Count: 5 Requests Per Secs: 0.18795579281101 5xx num: 0
license
MIT License.
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!