Github
实时监控 Nginx 域名的 qps, 5xx 个数,响应时长, 其中 ganglia_conf
目录是 ganglia 监控脚本。
nginx.conf
http {
...
...
lua_shared_dict statics_dict 1M; # 初始化变量
lua_package_path "/etc/nginx/ngx_reqstatus_lua/?.lua"; #路径
server {
listen 80;
server_name justforfun.com;
# 在需要监控的 server_name 添加此句
log_by_lua_file "/etc/nginx/ngx_reqstatus_lua/hook.lua";
location /{
...
...
}
}
# 监控服务
server {
listen 127.0.0.1:6080;
location /{
access_by_lua_file "/etc/nginx/ngx_reqstatus_lua/status.lua";
}
}
}
justforfun.com
的命令curl localhost:6080/?domain=justforfun.com
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
1
Senorsen 2015-12-26 19:41:31 +08:00 via Android
有 sample 嘛
|
2
zhengji OP 首先你要安装好 nginx lua [参考]( http://zheng-ji.info/blog/2015/10/29/gei-tengine-jia-shang-lua-tuo-zhan/)
之后按照上述配置 nginx.conf 就好了 |