diff options
author | Kaushal M <kaushal@gluster.com> | 2011-10-31 10:02:16 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-11-03 02:04:31 -0700 |
commit | 3200a2be434c462b43bf3ffe0343ddc8900c5d88 (patch) | |
tree | 270e51793de149407796f53a1172a1a0e4eae2ff | |
parent | 32173e1c70dcb53470b0738ed4d0022388193113 (diff) |
cli : Modify "top read-perf/write-perf" output
Improves alignment and width of columns in the output of "top
read-perf/write-perf".
Change-Id: I9a4ec3a121f40e099c96952e2388b27ed90b6fe6
BUG: 3719
Reviewed-on: http://review.gluster.com/645
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r-- | cli/src/cli-rpc-ops.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 86904af758d..55566d8c574 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -28,6 +28,15 @@ #endif #define DEFAULT_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" +/* Widths of various columns in top read/write-perf output + * Total width of top read/write-perf should be 80 chars + * including one space between column + */ +#define VOL_TOP_PERF_FILENAME_DEF_WIDTH 47 +#define VOL_TOP_PERF_FILENAME_ALT_WIDTH 44 +#define VOL_TOP_PERF_SPEED_WIDTH 4 +#define VOL_TOP_PERF_TIME_WIDTH 26 + #include "cli.h" #include "compat-errno.h" #include "cli-cmd.h" @@ -3534,7 +3543,14 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov, if (!members) { continue; } - cli_out ("MBps\t\tfilename\t\t time\n========================"); + cli_out ("%*s %-*s %-*s", + VOL_TOP_PERF_SPEED_WIDTH, "MBps", + VOL_TOP_PERF_FILENAME_DEF_WIDTH, "Filename", + VOL_TOP_PERF_TIME_WIDTH, "Time"); + cli_out ("%*s %-*s %-*s", + VOL_TOP_PERF_SPEED_WIDTH, "====", + VOL_TOP_PERF_FILENAME_DEF_WIDTH, "========", + VOL_TOP_PERF_TIME_WIDTH, "===="); break; default: goto out; @@ -3565,8 +3581,23 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov, strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm); snprintf (timestr + strlen (timestr), 256 - strlen (timestr), ".%"GF_PRI_SUSECONDS, time_usec); - - cli_out ("%"PRIu64"\t\t%s\t\t%s", value, filename, timestr); + if (strlen (filename) < VOL_TOP_PERF_FILENAME_DEF_WIDTH) + cli_out ("%*"PRIu64" %-*s %-*s", + VOL_TOP_PERF_SPEED_WIDTH, + value, + VOL_TOP_PERF_FILENAME_DEF_WIDTH, + filename, + VOL_TOP_PERF_TIME_WIDTH, + timestr); + else + cli_out ("%*"PRIu64" ...%-*s %-*s", + VOL_TOP_PERF_SPEED_WIDTH, + value, + VOL_TOP_PERF_FILENAME_ALT_WIDTH , + filename + strlen (filename) - + VOL_TOP_PERF_FILENAME_ALT_WIDTH, + VOL_TOP_PERF_TIME_WIDTH, + timestr); } else { cli_out ("%"PRIu64"\t\t%s", value, filename); } |