Make feature #1289 compatible with multiple keys

This commit is contained in:
nicolargo 2024-10-13 17:45:45 +02:00
parent 119add783e
commit 4afe46a2cb
4 changed files with 19 additions and 4 deletions

View File

@ -525,7 +525,7 @@ disable=False
# Define columns (comma separated list of <plugin>:<field>:(<key>)) to grab/display
# Default is: system:hr_name,load:min5,cpu:total,mem:percent
# You can also add stats with key, like sensors:value:Ambient (key is case sensitive)
#columns=system:hr_name,load:min5,cpu:total,mem:percent,memswap:percent
#columns=system:hr_name,load:min5,cpu:total,mem:percent,memswap:percent,sensors:value:Ambient,sensors:value:Composite
# Define the static servers list
#server_1_name=localhost
#server_1_alias=My local PC

View File

@ -525,7 +525,7 @@ disable=False
# Define columns (comma separated list of <plugin>:<field>:(<key>)) to grab/display
# Default is: system:hr_name,load:min5,cpu:total,mem:percent
# You can also add stats with key, like sensors:value:Ambient (key is case sensitive)
#columns=system:hr_name,load:min5,cpu:total,mem:percent,memswap:percent
#columns=system:hr_name,load:min5,cpu:total,mem:percent,memswap:percent,sensors:value:Ambient,sensors:value:Composite
# Define the static servers list
#server_1_name=localhost
#server_1_alias=My local PC

View File

@ -93,7 +93,9 @@ class GlancesClientBrowser:
# Get the stats
for column in self.static_server.get_columns():
server_key = column['plugin'] + '_' + column['field']
server_key = column.get('plugin') + '_' + column.get('field')
if 'key' in column:
server_key += '_' + column.get('key')
try:
# Value
v_json = json_loads(s.getPlugin(column['plugin']))

View File

@ -315,8 +315,21 @@ class GlancesCursesBrowser(_GlancesCurses):
y = 2
xc = x + 2
for k, v in column_def.items():
k_split = k.split('_')
if len(k_split) == 1:
xc += v + self.space_between_column
continue
if xc < screen_x and y < screen_y and v is not None:
self.term_window.addnstr(y, xc, k.split('_')[0].upper(), screen_x - x, self.colors_list['BOLD'])
self.term_window.addnstr(y, xc, k_split[0].upper(), screen_x - x, self.colors_list['BOLD'])
xc += v + self.space_between_column
xc = x + 2
y += 1
for k, v in column_def.items():
k_split = k.split('_')
if xc < screen_x and y < screen_y and v is not None:
self.term_window.addnstr(
y, xc, k_split[len(k_split) - 1].upper(), screen_x - x, self.colors_list['BOLD']
)
xc += v + self.space_between_column
y += 1