Flip the x and y axes in the on-screen table
shown by cluster monitor.py, so that nodes are
on the vertical axis while shards are across.
This is to make the output more readable when
there is a large number of nodes (e.g. > 10)
in the cluster vs. the typically small number
of shards.
Change-Id: If866d1409bf143391d7f020fa72a82d03be456df
Signed-off-by: Gary Wu <Gary.Wu1@huawei.com>
try:
with open('cluster.json') as cluster_file:
data = json.load(cluster_file)
try:
with open('cluster.json') as cluster_file:
data = json.load(cluster_file)
Shards.add(shardName)
print controller_names
print Shards
Shards.add(shardName)
print controller_names
print Shards
+field_len = max(map(len, Shards))+2
stdscr = curses.initscr()
curses.noecho()
stdscr = curses.initscr()
curses.noecho()
curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_YELLOW)
# display controller and shard headers
curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_YELLOW)
# display controller and shard headers
-for data_column, controller in enumerate(controller_names):
- stdscr.addstr(0, field_len * (data_column + 1), string.center(controller, field_len), curses.color_pair(1))
-for row, shard in enumerate(Shards):
- stdscr.addstr(row + 1, 0, shard, curses.color_pair(1))
+for row, controller in enumerate(controller_names):
+ stdscr.addstr(row + 1, 0, string.center(controller, field_len), curses.color_pair(1))
+for data_column, shard in enumerate(Shards):
+ stdscr.addstr(0, (field_len+1) * (data_column + 1), string.center(shard, field_len), curses.color_pair(1))
stdscr.addstr(len(Shards) + 2, 0, 'Press q to quit.', curses.color_pair(1))
stdscr.refresh()
stdscr.addstr(len(Shards) + 2, 0, 'Press q to quit.', curses.color_pair(1))
stdscr.refresh()
odd_or_even += 1
key = stdscr.getch()
odd_or_even += 1
key = stdscr.getch()
- for row, shard_name in enumerate(Shards):
+ for data_column, shard_name in enumerate(Shards):
cluster_stat = getClusterRolesWithCurl(shard_name, controllers, controller_names)
cluster_stat = getClusterRolesWithCurl(shard_name, controllers, controller_names)
- for data_column, controller in enumerate(controllers):
+ for row, controller in enumerate(controllers):
status = size_and_color(cluster_stat, field_len, controller)
status = size_and_color(cluster_stat, field_len, controller)
- stdscr.addstr(row + 1, field_len * (data_column + 1), status['txt'], status['color'])
+ stdscr.addstr(row + 1, (field_len+1) * (data_column + 1), status['txt'], status['color'])
time.sleep(0.5)
if odd_or_even % 2 == 0:
stdscr.addstr(0, field_len/2 - 2, " <3 ", curses.color_pair(5))
time.sleep(0.5)
if odd_or_even % 2 == 0:
stdscr.addstr(0, field_len/2 - 2, " <3 ", curses.color_pair(5))