From c0a98cc7d2114a0ea87d198b89bfd2bf752c1621 Mon Sep 17 00:00:00 2001 From: Nicolargo Date: Tue, 2 Dec 2014 19:17:43 +0100 Subject: [PATCH] Correct browser mode issue and alias name --- conf/glances-test.conf | 1 + glances/core/glances_staticlist.py | 2 +- glances/outputs/glances_curses.py | 12 ++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/conf/glances-test.conf b/conf/glances-test.conf index 13451371..5e930388 100644 --- a/conf/glances-test.conf +++ b/conf/glances-test.conf @@ -134,6 +134,7 @@ list_2_countmin=1 [serverlist] # Define the static server list server_1_name=localhost +server_1_alias=MonXPS server_1_port=61234 server_2_name=localhost server_2_port=61235 diff --git a/glances/core/glances_staticlist.py b/glances/core/glances_staticlist.py index a4be3402..955d3a6f 100644 --- a/glances/core/glances_staticlist.py +++ b/glances/core/glances_staticlist.py @@ -53,7 +53,7 @@ class GlancesStaticServer(object): new_server = {} postfix = 'server_%s_' % str(i) # Read the server name (mandatory) - for s in ['name', 'port']: + for s in ['name', 'port', 'alias']: new_server[s] = config.get_raw_option(self._section, '%s%s' % (postfix, s)) if new_server['name'] is not None: # Manage optionnal information diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index ad8db8c5..b8507623 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -1003,6 +1003,7 @@ class GlancesCursesBrowser(_GlancesCurses): # Item description: [stats_id, column name, column size] column_def = [ ['name', _('Name'), 16], + ['alias', None, None], ['load_min5', _('LOAD'), 6], ['cpu_percent', _('CPU%'), 5], ['mem_percent', _('MEM%'), 5], @@ -1017,7 +1018,7 @@ class GlancesCursesBrowser(_GlancesCurses): cpt = 0 xc = x + 2 for c in column_def: - if xc < screen_x and y < screen_y: + if xc < screen_x and y < screen_y and c[1] is not None: self.term_window.addnstr(y, xc, c[1], screen_x - x, @@ -1044,6 +1045,9 @@ class GlancesCursesBrowser(_GlancesCurses): logger.debug( "Can not grab stats {0} from server (KeyError: {1})".format(c[0], e)) server_stat[c[0]] = '?' + # Display alias instead of name + if c[0] == 'alias' and v[c[0]] is not None: + server_stat['name'] = v[c[0]] # Display line for server stats cpt = 0 @@ -1057,9 +1061,13 @@ class GlancesCursesBrowser(_GlancesCurses): screen_x - xc, self.colors_list['BOLD']) + # Display alias instead of name + server_stat + + # Display the line xc += 2 for c in column_def: - if xc < screen_x and y < screen_y: + if xc < screen_x and y < screen_y and c[1] is not None: # Display server stats self.term_window.addnstr(y, xc, "%s" % server_stat[c[0]],