用下班时间写了一个 ngx lua 的拓展, GitHub。可以:
使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| 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"; } } }
|
1
| curl localhost:6080/?domain=justforfun.com
|
1 2 3 4 5 6
| Server Name: justforfun.com Seconds SinceLast: 1.4399998188019 secs Request Count: 1 Average Req Time: 0 secs Requests Per Secs: 0.69444453182781 5xx num: 0
|