http-sysguard #

Earlier versions is not tested.

Source: upstream source

Directives

sysguard #

syntax: sysguard on | off (on/off flag);  ·  context: http, server, location

Description: Enables or disables the module working.

sysguard_interval #

syntax: sysguard_interval 1 arg (duration in seconds);  ·  context: http, server, location

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

sysguard_load #

syntax: sysguard_load 1 arg;  ·  context: http, server, location

It also requires the /proc file system to get memory information. ## Embedded Variables The following embedded variables are provided: $sysguard_load The load of system.

sysguard_log_level #

syntax: sysguard_log_level 1 arg (enum);  ·  context: http, server, location

Description: Specify the log level of sysguard.

sysguard_mem #

syntax: sysguard_mem 1 arg;  ·  context: http, server, location

Defines a swap-usage-ratio or free-memory threshold beyond which requests get redirected to an action URL or rejected with 503.

sysguard_mode #

syntax: sysguard_mode on | off (enum);  ·  context: http, server, location

Description: If there are more than one type of monitor, this directive is used to specified the relations among all the monitors which are: 'and' for all matching and 'or' for any matching.

sysguard_rt #

syntax: sysguard_rt 1 arg;  ·  context: http, server, location

Description: Specify the response time threshold. Parameter rt is used to set a threshold of the average response time, in second. Parameter period is used to specify the period of the statistics cycle. If the average response time of the system exceeds the threshold specified by the user, The default method is set to be method=AMM:period.

Example

http {

    ...

    server {

        ...

        sysguard on;
        sysguard_mode or;

        sysguard_load load=10.5 action=/loadlimit;
        sysguard_mem swapratio=20% action=/swaplimit;
        sysguard_mem free=100M action=/freelimit;
        sysguard_rt rt=0.01 period=5s method=AMM:10 action=/rtlimit;

        location /loadlimit {
            return 503;
        }

        location /swaplimit {
            return 503;
        }

        location /freelimit {
            return 503;
        }

        location /rtlimit {
            return 503;
        }
    }

    ...

    server {

        ...

        location /api {
            sysguard on;
            sysguard_mode or;
            sysguard_load load=20 action=/limit;
            sysguard_mem swapratio=10% action=/limit;
            sysguard_rt rt=2.01 period=5s method=WMA:10 action=/limit;

            ... 

        }

        location /images {
            sysguard on;
            sysguard_mode and;
            sysguard_load load=20 action=/limit;
            sysguard_mem swapratio=10% action=/limit;
            sysguard_rt rt=2.01 period=5s method=WMA:10 action=/limit;

            ...

        }

        location /limit {
            return 503;
        }
    }

}

↑ back to index