Giter Site home page Giter Site logo

ngx_lua_reqstatus's Introduction

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 /{
            content_by_lua_file "/etc/nginx/ngx_lua_reqstatus/status.lua";
        }
    }
}

效果

  • 查看 域名 justforfun.com 的qps,5xx个数,平均响应时长:

ganglia

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
  • 如果对你有帮助, 请我喝杯咖啡吧 :)

wechatqr

license

MIT License.

ngx_lua_reqstatus's People

Contributors

zheng-ji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx_lua_reqstatus's Issues

unknown directive "lua_shared_dict"

Stoping nginx... nginx: [emerg] unknown directive "lua_shared_dict" in /usr/local/nginx/conf/nginx.conf:59
failed. Use force-quit

重启nginx会报上面的错是为什么 nginx version: nginx/1.10.0

who aer your? please help me.

git clone ....

drwxr-xr-x 2 root root 4096 Feb 15 11:41 conf.d
-rw-r--r-- 1 root root  964 Apr 21  2015 fastcgi_params
-rw-r--r-- 1 root root 2837 Apr 21  2015 koi-utf
-rw-r--r-- 1 root root 2223 Apr 21  2015 koi-win
-rw-r--r-- 1 root root 3957 Apr 21  2015 mime.types
-rw-r--r-- 1 root root 1496 Feb 15 11:49 nginx.conf
-rw-r--r-- 1 root root  954 Feb 15 11:38 nginx.conf_bak
drwxr-xr-x 4 root root 4096 Feb 15 11:45 ngx_lua_reqstatus
-rw-r--r-- 1 root root  596 Apr 21  2015 scgi_params
-rw-r--r-- 1 root root  623 Apr 21  2015 uwsgi_params
-rw-r--r-- 1 root root 3610 Apr 21  2015 win-utf

vi ....


     45     #QPS监控
     46     lua_shared_dict statics_dict    1M; # 初始化变量
     47     lua_package_path "/etc/nginx/ngx_lua_reqstatus/?.lua";  #路径
     48     log_by_lua_file "/etc/nginx/ngx_lua_reqstatus/hook.lua"; #  添加此句
     49 
     50     server {
     51         listen 80;
     52         server_name feichuanbuke.com;     
     53         location /{
     54             ...
     55         }
     56     }
     57 
     58     # 监控服务
     59     server {
     60         listen 127.0.0.1:6080;
     61         location /{
     62             content_by_lua_file "/etc/nginx/ngx_lua_reqstatus/status.lua";
     63         }
     64     }

/etc/init.d/nginx restart

`nginx: [emerg] unknown directive "lua_shared_dict" in /etc/nginx/nginx.conf:46
nginx: configuration file /etc/nginx/nginx.conf test failed`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.