dovecot-2.2: doveadm director ring status shows now more informa...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 11 23:52:46 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/ade6dcace5cd
changeset: 18062:ade6dcace5cd
user: Timo Sirainen <tss at iki.fi>
date: Wed Nov 12 01:51:29 2014 +0200
description:
doveadm director ring status shows now more information
diffstat:
src/director/director-connection.c | 5 +++
src/director/director-connection.h | 1 +
src/director/doveadm-connection.c | 60 +++++++++++++++++++++++++++++++++++++-
src/doveadm/doveadm-director.c | 4 +-
4 files changed, 68 insertions(+), 2 deletions(-)
diffs (133 lines):
diff -r aca0b7142046 -r ade6dcace5cd src/director/director-connection.c
--- a/src/director/director-connection.c Wed Nov 12 01:26:04 2014 +0200
+++ b/src/director/director-connection.c Wed Nov 12 01:51:29 2014 +0200
@@ -1841,6 +1841,11 @@
return conn->handshake_received;
}
+bool director_connection_is_synced(struct director_connection *conn)
+{
+ return conn->synced;
+}
+
bool director_connection_is_incoming(struct director_connection *conn)
{
return conn->in;
diff -r aca0b7142046 -r ade6dcace5cd src/director/director-connection.h
--- a/src/director/director-connection.h Wed Nov 12 01:26:04 2014 +0200
+++ b/src/director/director-connection.h Wed Nov 12 01:51:29 2014 +0200
@@ -23,6 +23,7 @@
struct director_host *
director_connection_get_host(struct director_connection *conn);
bool director_connection_is_handshaked(struct director_connection *conn);
+bool director_connection_is_synced(struct director_connection *conn);
bool director_connection_is_incoming(struct director_connection *conn);
unsigned int
director_connection_get_minor_version(struct director_connection *conn);
diff -r aca0b7142046 -r ade6dcace5cd src/director/doveadm-connection.c
--- a/src/director/doveadm-connection.c Wed Nov 12 01:26:04 2014 +0200
+++ b/src/director/doveadm-connection.c Wed Nov 12 01:51:29 2014 +0200
@@ -92,6 +92,59 @@
mail_hosts_deinit(&orig_hosts_list);
}
+static void doveadm_director_append_status(struct director *dir, string_t *str)
+{
+ if (!dir->ring_handshaked)
+ str_append(str, "handshaking");
+ else if (dir->ring_synced)
+ str_append(str, "synced");
+ else {
+ str_printfa(str, "syncing - last sync %d secs ago",
+ (int)(ioloop_time - dir->ring_last_sync_time));
+ }
+}
+
+static void
+doveadm_director_connection_append_status(struct director_connection *conn,
+ string_t *str)
+{
+ if (!director_connection_is_handshaked(conn))
+ str_append(str, "handshaking");
+ else if (director_connection_is_synced(conn))
+ str_append(str, "synced");
+ else
+ str_append(str, "syncing");
+}
+
+static void
+doveadm_director_host_append_status(struct director *dir,
+ const struct director_host *host,
+ string_t *str)
+{
+ struct director_connection *conn = NULL;
+
+ if (dir->left != NULL &&
+ director_connection_get_host(dir->left) == host)
+ conn = dir->left;
+ else if (dir->right != NULL &&
+ director_connection_get_host(dir->right) == host)
+ conn = dir->right;
+ else {
+ /* we might have a connection that is being connected */
+ struct director_connection *const *connp;
+
+ array_foreach(&dir->connections, connp) {
+ if (director_connection_get_host(*connp) == host) {
+ conn = *connp;
+ break;
+ }
+ }
+ }
+
+ if (conn != NULL)
+ doveadm_director_connection_append_status(conn, str);
+}
+
static void doveadm_cmd_director_list(struct doveadm_connection *conn)
{
struct director *dir = conn->dir;
@@ -122,9 +175,14 @@
last_failed = I_MAX(host->last_network_failure,
host->last_protocol_failure);
- str_printfa(str, "%s\t%u\t%s\t%lu\n",
+ str_printfa(str, "%s\t%u\t%s\t%lu\t",
net_ip2addr(&host->ip), host->port, type,
(unsigned long)last_failed);
+ if (dir->self_host == host)
+ doveadm_director_append_status(dir, str);
+ else
+ doveadm_director_host_append_status(dir, host, str);
+ str_append_c(str, '\n');
}
str_append_c(str, '\n');
o_stream_nsend(conn->output, str_data(str), str_len(str));
diff -r aca0b7142046 -r ade6dcace5cd src/doveadm/doveadm-director.c
--- a/src/doveadm/doveadm-director.c Wed Nov 12 01:26:04 2014 +0200
+++ b/src/doveadm/doveadm-director.c Wed Nov 12 01:51:29 2014 +0200
@@ -718,6 +718,7 @@
doveadm_print_header_simple("port");
doveadm_print_header_simple("type");
doveadm_print_header_simple("last failed");
+ doveadm_print_header_simple("status");
director_send(ctx, "DIRECTOR-LIST\n");
while ((line = i_stream_read_next_line(ctx->input)) != NULL) {
@@ -725,7 +726,7 @@
break;
T_BEGIN {
args = t_strsplit_tab(line);
- if (str_array_length(args) >= 4 &&
+ if (str_array_length(args) >= 5 &&
str_to_ulong(args[3], &l) == 0) {
doveadm_print(args[0]);
doveadm_print(args[1]);
@@ -734,6 +735,7 @@
doveadm_print("never");
else
doveadm_print(unixdate2str(l));
+ doveadm_print(args[4]);
}
} T_END;
}
More information about the dovecot-cvs
mailing list