]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Add RESET call to stats client
authorAki Tuomi <aki.tuomi@dovecot.net>
Mon, 11 Jan 2016 13:46:28 +0000 (15:46 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 15 Jan 2016 17:13:45 +0000 (19:13 +0200)
src/stats/Makefile.am
src/stats/client-reset.c [new file with mode: 0644]
src/stats/client-reset.h [new file with mode: 0644]
src/stats/client.c

index 96ddcdcabda67d328bf7f9d0ebf1535d6f9ab39b..e84ead1056f0d554f178426aa71678e0720eb93d 100644 (file)
@@ -16,6 +16,7 @@ stats_DEPENDENCIES = $(LIBDOVECOT_DEPS)
 stats_SOURCES = \
        client.c \
        client-export.c \
+       client-reset.c \
        global-memory.c \
        mail-command.c \
        mail-domain.c \
@@ -30,6 +31,7 @@ stats_SOURCES = \
 noinst_HEADERS = \
        client.h \
        client-export.h \
+       client-reset.h \
        global-memory.h \
        mail-command.h \
        mail-domain.h \
diff --git a/src/stats/client-reset.c b/src/stats/client-reset.c
new file mode 100644 (file)
index 0000000..d5a3967
--- /dev/null
@@ -0,0 +1,24 @@
+/* Copyright (c) 2011-2015 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "net.h"
+#include "ostream.h"
+#include "str.h"
+#include "strescape.h"
+#include "mail-stats.h"
+#include "mail-command.h"
+#include "mail-session.h"
+#include "mail-user.h"
+#include "mail-domain.h"
+#include "mail-ip.h"
+#include "client.h"
+#include "client-reset.h"
+
+int client_stats_reset(struct client *client, const char *const *args ATTR_UNUSED,
+                       const char **error_r ATTR_UNUSED)
+{
+       struct mail_global *g = &mail_global_stats;
+       stats_reset(g->stats);
+       o_stream_nsend_str(client->output, "OK\n");
+       return 0;
+}
diff --git a/src/stats/client-reset.h b/src/stats/client-reset.h
new file mode 100644 (file)
index 0000000..7a84d61
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef CLIENT_RESET_H
+#define CLIENT_RESET_H
+
+struct client;
+
+int client_stats_reset(struct client *client, const char *const *args,
+                       const char **error_r);
+
+#endif
index bd2686c6d857dac9c81645feba702f2ecea97a6a..a69668ee4a747819e0a1903bcae6edc20ead431e 100644 (file)
@@ -49,6 +49,8 @@ client_handle_request(struct client *client, const char *const *args,
 
        if (strcmp(cmd, "EXPORT") == 0)
                return client_export(client, args, error_r);
+       if (strcmp(cmd, "RESET") == 0)
+               return client_stats_reset(client, args, error_r);
 
        *error_r = "Unknown command";
        return -1;