From: Willy Tarreau Date: Wed, 7 Sep 2011 14:13:44 +0000 (+0200) Subject: [MEDIUM] stats: add the ability to adjust the global maxconnrate X-Git-Tag: v1.5-dev8~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5b22875cd92783e08482b467d4055e38decebe8;p=thirdparty%2Fhaproxy.git [MEDIUM] stats: add the ability to adjust the global maxconnrate Using "set rate-limit connections global " on the CLI, we can now adjust the per-process connection rate limiting (equal to global.maxconnrate). --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 62fc5e902c..ed09c32e05 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -9580,6 +9580,12 @@ set maxconn global delayed until the threshold is reached. A value of zero restores the initial setting. +set rate-limit connections global + Change the process-wide connection rate limit, which is set by the global + 'maxconnrate' setting. A value of zero disables the limitation. This limit + applies to all frontends and the change has an immediate effect. The value + is passed in number of connections per second. + set timeout cli Change the CLI interface timeout for current connection. This can be useful during long debugging sessions where the user needs to constantly inspect diff --git a/src/dumpstats.c b/src/dumpstats.c index 73d5ad649e..6d97f5da5a 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -85,6 +85,7 @@ static const char stats_sock_usage_msg[] = " disable server : set a server in maintenance mode\n" " enable server : re-enable a server that was previously in maintenance mode\n" " set maxconn : change a maxconn setting\n" + " set rate-limit : change a rate limiting value\n" ""; static const char stats_permission_denied_msg[] = @@ -1061,6 +1062,50 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) return 1; } } + else if (strcmp(args[1], "rate-limit") == 0) { + if (strcmp(args[2], "connections") == 0) { + if (strcmp(args[3], "global") == 0) { + int v; + + if (s->listener->perm.ux.level < ACCESS_LVL_ADMIN) { + si->applet.ctx.cli.msg = stats_permission_denied_msg; + si->applet.st0 = STAT_CLI_PRINT; + return 1; + } + + if (!*args[4]) { + si->applet.ctx.cli.msg = "Expects an integer value.\n"; + si->applet.st0 = STAT_CLI_PRINT; + return 1; + } + + v = atoi(args[4]); + if (v < 0) { + si->applet.ctx.cli.msg = "Value out of range.\n"; + si->applet.st0 = STAT_CLI_PRINT; + return 1; + } + + global.cps_lim = v; + + /* Dequeues all of the listeners waiting for a resource */ + if (!LIST_ISEMPTY(&global_listener_queue)) + dequeue_all_listeners(&global_listener_queue); + + return 1; + } + else { + si->applet.ctx.cli.msg = "'set rate-limit connections' only supports 'global'.\n"; + si->applet.st0 = STAT_CLI_PRINT; + return 1; + } + } + else { + si->applet.ctx.cli.msg = "'set rate-limit' only supports 'connections'.\n"; + si->applet.st0 = STAT_CLI_PRINT; + return 1; + } + } else { /* unknown "set" parameter */ return 0; }