>From caec2314421cb985237d9aa5a6bbb62e2f730910 Mon Sep 17 00:00:00 2001 From: Krzysztof Piotr Oledzki <o...@ans.pl> Date: Sun, 4 Oct 2009 15:02:46 +0200 Subject: [MINOR] Add "clear counters" to clear statistics counters
Now, when statistics counters are moved to separate structures, adding "clear counters" is extremely easy. --- doc/configuration.txt | 4 ++++ src/dumpstats.c | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index 254382b..cd3d17b 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -6724,6 +6724,10 @@ show stat [<iid> <type> <sid>] A similar empty line appears at the end of the second block (stats) so that the reader knows the output has not been trucated. +clear counters + Clear statistics counters in each proxy (frontend & backend) and in each + server. + /* * Local variables: * fill-column: 79 diff --git a/src/dumpstats.c b/src/dumpstats.c index 024448a..2b704af 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -305,11 +305,29 @@ int stats_sock_parse_request(struct stream_interface *si, char *line) s->ana_state = STATS_ST_REP; si->st0 = 5; // stats_dump_errors_to_buffer } - else { /* neither "stat" nor "info" nor "sess" */ + else { /* neither "stat" nor "info" nor "sess" nor "errors"*/ return 0; } } - else { /* not "show" */ + else if (strcmp(args[0], "clear") == 0) { + if (strcmp(args[1], "counters") == 0) { + struct proxy *px; + struct server *sv; + + for (px = proxy; px; px = px->next) { + memset(&px->counters, 0, sizeof(px->counters)); + + for (sv = px->srv; sv; sv = sv->next) + memset(&sv->counters, 0, sizeof(sv->counters)); + } + + return 1; + } + else { + return 0; + } + } + else { /* not "show" nor "clear"*/ return 0; } return 1; -- 1.6.4.2