diff options
author | Kaushal M <kaushal@gluster.com> | 2011-10-31 10:02:16 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-11-04 02:09:48 -0700 |
commit | 62704943d42e81b7b5a5aec6e248abb90af11010 (patch) | |
tree | b9aa14a9c179c9a324947e6efa7bf8f49f93ad5a | |
parent | 8e171a03d81452a2998b01997da7647c0b3bf52b (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: I96904fb10e10c184473d5224fb09093721d93f88
BUG: 3719
Reviewed-on: http://review.gluster.com/649
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 9b91637ddad..94db9787ed2 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" @@ -3305,7 +3314,14 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov, cli_out ("No entries in list"); 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; @@ -3336,8 +3352,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); } |