changeset 22630:0170e1657f4d

doveadm director ring status: Add more fields related to connection status
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 26 Oct 2017 14:10:51 +0300
parents 0281041d5067
children 53082f1df8a6
files src/director/doveadm-connection.c src/doveadm/doveadm-director.c
diffstat 2 files changed, 31 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/doveadm-connection.c	Thu Oct 26 14:18:50 2017 +0300
+++ b/src/director/doveadm-connection.c	Thu Oct 26 14:10:51 2017 +0300
@@ -155,18 +155,29 @@
 		str_printfa(str, "syncing - last sync %d secs ago",
 			    (int)(ioloop_time - dir->ring_last_sync_time));
 	}
+	str_printfa(str, "\t%u", dir->last_sync_msecs);
 }
 
 static void
 doveadm_director_connection_append_status(struct director_connection *conn,
 					  string_t *str)
 {
+	struct director_connection_status status;
+
 	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");
+
+	director_connection_get_status(conn, &status);
+	str_printfa(str, "\t%u\t%"PRIuUOFF_T"\t%"PRIuUOFF_T"\t%zu\t%zu\t"
+		    "%ld\t%ld", status.last_ping_msecs,
+		    status.bytes_read, status.bytes_sent,
+		    status.bytes_buffered, status.peak_bytes_buffered,
+		    (long)status.last_input.tv_sec,
+		    (long)status.last_output.tv_sec);
 }
 
 static void
--- a/src/doveadm/doveadm-director.c	Thu Oct 26 14:18:50 2017 +0300
+++ b/src/doveadm/doveadm-director.c	Thu Oct 26 14:10:51 2017 +0300
@@ -872,26 +872,36 @@
 	doveadm_print_header_simple("type");
 	doveadm_print_header_simple("last failed");
 	doveadm_print_header_simple("status");
+	doveadm_print_header_simple("ping ms");
+	doveadm_print_header_simple("input");
+	doveadm_print_header_simple("output");
+	doveadm_print_header_simple("buffered");
+	doveadm_print_header_simple("buffered peak");
+	doveadm_print_header_simple("last read");
+	doveadm_print_header_simple("last write");
 
 	director_send(ctx, "DIRECTOR-LIST\n");
 	while ((line = i_stream_read_next_line(ctx->input)) != NULL) {
 		if (*line == '\0')
 			break;
 		T_BEGIN {
+			unsigned int i;
 			time_t ts;
 
 			args = t_strsplit_tabescaped(line);
-			if (str_array_length(args) >= 5 &&
-			    str_to_time(args[3], &ts) == 0) {
-				doveadm_print(args[0]);
-				doveadm_print(args[1]);
-				doveadm_print(args[2]);
-				if (ts == 0)
-					doveadm_print("never");
-				else
-					doveadm_print(unixdate2str(ts));
-				doveadm_print(args[4]);
+			for (i = 0; i < 12 && args[i] != NULL; i++) {
+				if ((i == 3 || i == 10 || i == 11) &&
+				    str_to_time(args[i], &ts) == 0) {
+					if (ts == 0)
+						doveadm_print("never");
+					else
+						doveadm_print(unixdate2str(ts));
+				} else {
+					doveadm_print(args[i]);
+				}
 			}
+			for (; i < 12; i++)
+				doveadm_print("-");
 		} T_END;
 	}
 	if (line == NULL)