Skip to content

Commit

Permalink
Make feature #1289 compatible with multiple keys
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo committed Oct 13, 2024
1 parent 119add7 commit 4afe46a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion conf/glances.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/glances.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion glances/client_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def __update_stats(self, server):

# 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']))
Expand Down
15 changes: 14 additions & 1 deletion glances/outputs/glances_curses_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,21 @@ def __display_server_list(self, stats, x, y, screen_x, screen_y):
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'])
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('_')[0].upper(), screen_x - x, self.colors_list['BOLD'])
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

Expand Down

0 comments on commit 4afe46a

Please sign in to comment.