@@ -760,26 +760,35 @@ class FSTop(object):
760760 global metrics_dict , current_states
761761 counters = [m .upper () for m in stats_json [GLOBAL_COUNTERS_KEY ]]
762762 self .tablehead_y += 2
763- res = stats_json [CLIENT_METADATA_KEY ].get (fs_name , {})
763+ res = stats_json [GLOBAL_METRICS_KEY ].get (fs_name , {})
764764 client_cnt = len (res )
765765 self .fsstats .addstr (self .tablehead_y , 0 , FS_TOP_NAME_TOPL_FMT .format (
766766 fs_name = fs_name , client_count = client_cnt ), curses .A_BOLD | curses .A_ITALIC )
767767 self .tablehead_y += 2
768+ metrics_dict_client = metrics_dict .get (fs_name , {})
769+ if len (metrics_dict ) > len (fs_list ):
770+ stale_fs = set (metrics_dict ) - set (fs_list )
771+ for key in stale_fs :
772+ del metrics_dict [key ]
773+ if len (metrics_dict_client ) > client_cnt :
774+ stale_clients = set (metrics_dict_client ) - set (res )
775+ for key in stale_clients :
776+ del metrics_dict_client [key ]
768777 if client_cnt :
769- if len (metrics_dict . get ( fs_name , {}) ) != client_cnt :
770- sort_list = sorted (list (stats_json [ GLOBAL_METRICS_KEY ]. get ( fs_name , {}) .keys ()))
778+ if len (metrics_dict_client ) != client_cnt :
779+ sort_list = sorted (list (res .keys ()))
771780 else :
772781 sort_arg = current_states ['last_field' ]
773- sort_list = sorted (list (stats_json [ GLOBAL_METRICS_KEY ]. get ( fs_name , {}) .keys ()),
782+ sort_list = sorted (list (res .keys ()),
774783 key = lambda x : metrics_dict [fs_name ].get (x , {}).get (sort_arg , 0 ),
775784 reverse = True )
776785 if current_states ['limit' ] is not None and int (current_states ['limit' ]) < client_cnt :
777786 sort_list = sort_list [0 :int (current_states ['limit' ])]
778787 for client_id in sort_list :
779788 self .create_client (
780- fs_name , client_id ,
781- stats_json [GLOBAL_METRICS_KEY ].get (fs_name , {}).get (client_id , {}),
782- counters , res . get ( client_id , {}), self .tablehead_y )
789+ fs_name , client_id , res . get ( client_id , {}), counters ,
790+ stats_json [CLIENT_METADATA_KEY ].get (fs_name , {}).get (client_id , {}),
791+ self .tablehead_y )
783792 self .tablehead_y += 1
784793
785794 def create_header (self , stats_json , help , screen_title = "" , color_id = 0 ):
@@ -864,7 +873,7 @@ class FSTop(object):
864873 help = "COMMANDS: " + help_commands
865874 self .fsstats .erase () # erase previous text
866875
867- client_metadata = stats_json [CLIENT_METADATA_KEY ].get (fs , {})
876+ client_metadata = stats_json [GLOBAL_METRICS_KEY ].get (fs , {})
868877 if current_states ['limit' ] is not None and \
869878 int (current_states ['limit' ]) < len (client_metadata ):
870879 num_client = int (current_states ['limit' ])
@@ -993,7 +1002,7 @@ class FSTop(object):
9931002 self .fsstats .erase () # erase previous text
9941003 for index , fs in enumerate (fs_list ):
9951004 # Get the vscrollEnd in advance
996- client_metadata = stats_json [CLIENT_METADATA_KEY ].get (fs , {})
1005+ client_metadata = stats_json [GLOBAL_METRICS_KEY ].get (fs , {})
9971006 if current_states ['limit' ] is not None and \
9981007 int (current_states ['limit' ]) < len (client_metadata ):
9991008 num_client = int (current_states ['limit' ])
0 commit comments