mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-19 12:10:46 +00:00
[MEDIUM] stats: add the ability to adjust the global maxconnrate
Using "set rate-limit connections global <xxx>" on the CLI, we can now adjust the per-process connection rate limiting (equal to global.maxconnrate).
This commit is contained in:
parent
9cd552d8f4
commit
f5b22875cd
@ -9580,6 +9580,12 @@ set maxconn global <maxconn>
|
||||
delayed until the threshold is reached. A value of zero restores the initial
|
||||
setting.
|
||||
|
||||
set rate-limit connections global <value>
|
||||
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 <delay>
|
||||
Change the CLI interface timeout for current connection. This can be useful
|
||||
during long debugging sessions where the user needs to constantly inspect
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user