Add a 'stats disable' option that can be used to explicitly disable the
stats, without issuing the warning message as seen on TCP proxies.
If any stats options are present in a default block, there is presently
no way to explicitly disable them for a single proxy, other than
defining a new default block with all of the options repeated EXCEPT the
stats options.
This normally generates a warning:
[WARNING] ... 'stats' statement ignored for proxy 'my-proxy' as it
requires HTTP mode.
After the warning is issued, the stats for that proxy are disabled
anyway.
The new 'stats disable' option just disables the stats without
generating the warning message; it uses the exact same means to disable
the stats as used by the warning path.
This patch should be back-ported to 1.7.
Signed-off-by: Robin H. Johnson <[email protected]>
---
doc/configuration.txt | 12 +++++++++++-
src/cfgparse.c | 4 +++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/doc/configuration.txt b/doc/configuration.txt
index f24c39623..18992d37e 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -1944,6 +1944,7 @@ srvtimeout (deprecated) X -
X X
stats admin - X X X
stats auth X X X X
stats enable X X X X
+stats disable X X X X
stats hide-version X X X X
stats http-request - X X X
stats realm X X X X
@@ -7769,8 +7770,17 @@ stats enable
stats uri /admin?stats
stats refresh 5s
- See also : "stats auth", "stats realm", "stats uri"
+ See also : "stats auth", "stats realm", "stats uri", "stats disable"
+stats disable
+ Disable statistics reporting.
+ May be used in sections : defaults | frontend | listen | backend
+ yes | yes | yes | yes
+ Arguments : none
+
+ This statement explicitly disables statistics reporting.
+
+ See also : "stats enable"
stats hide-version
Enable statistics and hide HAProxy version reporting
diff --git a/src/cfgparse.c b/src/cfgparse.c
index ec8f6a1f0..1c65bf398 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -4498,6 +4498,8 @@ int cfg_parse_listen(const char *file, int linenum, char
**args, int kwm)
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
+ } else if (!strcmp(args[1], "disable")) {
+ curproxy->uri_auth = NULL;
} else if (!strcmp(args[1], "enable")) {
if (!stats_check_init_uri_auth(&curproxy->uri_auth)) {
Alert("parsing [%s:%d] : out of memory.\n",
file, linenum);
@@ -4574,7 +4576,7 @@ int cfg_parse_listen(const char *file, int linenum, char
**args, int kwm)
}
} else {
stats_error_parsing:
- Alert("parsing [%s:%d]: %s '%s', expects 'admin',
'uri', 'realm', 'auth', 'scope', 'enable', 'hide-version', 'show-node',
'show-desc' or 'show-legends'.\n",
+ Alert("parsing [%s:%d]: %s '%s', expects 'admin',
'uri', 'realm', 'auth', 'scope', 'enable', 'disable', 'hide-version',
'show-node', 'show-desc' or 'show-legends'.\n",
file, linenum, *args[1]?"unknown stats
parameter":"missing keyword in", args[*args[1]?1:0]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
--
2.11.0.rc2