dovecot-2.1: doveadm stats top: Added -b parameter to use read_b...

dovecot at dovecot.org dovecot at dovecot.org
Fri Dec 30 17:44:47 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/193c66096bb3
changeset: 13879:193c66096bb3
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Dec 30 17:44:23 2011 +0200
description:
doveadm stats top: Added -b parameter to use read_bytes/write_bytes fields for disk io.
This is useful when the kernel doesn't support the actual disk IO fields.

diffstat:

 src/doveadm/doveadm-stats.c |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diffs (61 lines):

diff -r 5df67a23afb9 -r 193c66096bb3 src/doveadm/doveadm-stats.c
--- a/src/doveadm/doveadm-stats.c	Fri Dec 30 12:33:06 2011 +0200
+++ b/src/doveadm/doveadm-stats.c	Fri Dec 30 17:44:23 2011 +0200
@@ -48,6 +48,8 @@
 };
 
 static struct top_context *sort_ctx = NULL;
+static const char *disk_input_field = "disk_input";
+static const char *disk_output_field = "disk_output";
 
 static char **
 p_read_next_line(pool_t pool, struct istream *input)
@@ -318,8 +320,8 @@
 		return;
 	}
 	if (strcmp(ctx->sort_type, "disk") == 0) {
-		if (!stats_header_find(ctx, "disk_input", &ctx->sort_idx1) ||
-		    !stats_header_find(ctx, "disk_output", &ctx->sort_idx2))
+		if (!stats_header_find(ctx, disk_input_field, &ctx->sort_idx1) ||
+		    !stats_header_find(ctx, disk_output_field, &ctx->sort_idx2))
 			i_fatal("disk sort type is missing fields");
 		return;
 	}
@@ -407,12 +409,15 @@
 {
 	static const char *names[] = {
 		"user", "service", "user_cpu", "sys_cpu",
-		"disk_input", "disk_output"
+		"", ""
 	};
 	struct winsize ws;
 	struct top_line *const *lines;
 	unsigned int i, j, row, maxrow, count, indexes[N_ELEMENTS(names)];
 
+	names[4] = disk_input_field;
+	names[5] = disk_output_field;
+
 	/* ANSI clear screen and move cursor to top of screen */
 	printf("\x1b[2J\x1b[1;1H"); fflush(stdout);
 	doveadm_print_deinit();
@@ -499,8 +504,12 @@
 
 	path = t_strconcat(doveadm_settings->base_dir, "/stats", NULL);
 
-	while ((c = getopt(argc, argv, "s:")) > 0) {
+	while ((c = getopt(argc, argv, "bs:")) > 0) {
 		switch (c) {
+		case 'b':
+			disk_input_field = "read_bytes";
+			disk_output_field = "write_bytes";
+			break;
 		case 's':
 			path = optarg;
 			break;
@@ -525,5 +534,5 @@
 };
 
 struct doveadm_cmd doveadm_cmd_stats_top = {
-	cmd_stats_top, "stats top", "[-s <stats socket path>] [<sort field>]"
+	cmd_stats_top, "stats top", "[-s <stats socket path>] [-b] [<sort field>]"
 };


More information about the dovecot-cvs mailing list