Giter VIP home page Giter VIP logo

nginx-http-sysguard's Introduction

##Description

This module can be used to protect your server in case system load or memory use goes too high.
It comes from Tengine, an Nginx distribution with quite a few advanced features.

###Examples:

server {
    sysguard on;

    sysguard_load load=10.5 action=/loadlimit;
    sysguard_mem swapratio=20% action=/swaplimit;

    location /loadlimit {
        return 503;
    }

    location /swaplimit {
        return 503;
    }
}

##Installation

$ wget http://www.nginx.org/download/nginx-1.2.5.tar.gz
$ tar xzvf nginx-1.2.5.tar.gz

$ cd nginx-1.2.5
$ git clone https://github.com/taobao/nginx-http-sysguard.git
$ patch -p1 < nginx-http-sysguard/nginx_sysguard_1.2.5.patch

$ ./configure --add-module=./nginx-http-sysguard
# make && make install

##Directives

Syntax: sysguard [on | off]
Default: sysguard off
Context: http, server, location

Turn on or off this module.

Syntax: sysguard_load load=number [action=/url]
Default: none
Context: http, server, location

Specify the load threshold. When the system load exceeds this threshold, all subsequent requests will be redirected to the URL specified by the 'action' parameter. Nginx will return 503 if there's no 'action' URL defined.

Syntax: sysguard_mem swapratio=ratio% [action=/url]
Default: none
Context: http, server, location

Specify the used swap memory threshold. When the swap memory use ratio exceeds this threshold, all subsequent requests will be redirected to the URL specified by the 'action' parameter. Nginx will return 503 if there's no 'action' URL.

Syntax: sysguard_interval time
Default: sysguard_interval 1s
Context: http, server, location

Specify the time interval to update your system information. The default value is one second, which means Nginx updates the server status once a second.

Syntax: sysguard_log_level [info | notice | warn | error]
Default: sysguard_log_level error
Context: http, server, location
Specify the log level of sysguard.

nginx-http-sysguard's People

Contributors

zhuzhaoyuan 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  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

nginx-http-sysguard's Issues

About the patch

How about using module context to save the state instead of providing a patch?

something like

line 188

--if (r->main->sysguard_set) {
++ctx = ngx_http_get_module_ctx(r, ngx_http_sysguard_module);
++if (ctx != NULL || r->internal) {

Unclear documentation

  1. What is meant by system load is this the same load metric that you get from, e.g.,
    uptime in Linux? In that case is an average and it requires some [thinking](https://en.wikipedia.org/wiki/Load_(computing\)) to set it to a given value.

  2. What can the action parameter do? Is it merely an internal redirection to a location or can it redirect
    to an external location or do more complex things?

  3. The swap ratio is relative to the maximum available? I think so but it should be made clear.
    Is it something like what you get from (Linux):

     cat /proc/meminfo | awk '/^SwapTotal:/ {spt=$2} /^SwapFree:/ {spf=$2}
     END {printf("| swp %d%%",(1-spf/spt)*100)}'
    

how to override nginx default page

error_page 500 502 503 504 /torii_50x.html;

location = /torii_50x.html {
    root /usr/local/nginx/html/;
}

location /loadlimit {
    return 503;
}

This configuration still returns default nginx 503 error page, but not the content of torii_50x.html

can you please explain how to override default nginx error page for sysguard module?

Thanks

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.