mirror of https://github.com/nicolargo/glances.git
Show used port in container section - First try, ok for one port... #2054
This commit is contained in:
parent
01b4ca1cf5
commit
f705193848
|
|
@ -70,6 +70,9 @@ fields_description = {
|
|||
'description': 'Container network TX bitrate',
|
||||
'unit': 'bitpersecond',
|
||||
},
|
||||
'ports': {
|
||||
'description': 'Container ports',
|
||||
},
|
||||
'uptime': {
|
||||
'description': 'Container uptime',
|
||||
},
|
||||
|
|
@ -375,6 +378,9 @@ class PluginModel(GlancesPluginModel):
|
|||
if 'networkio' not in self.disable_stats:
|
||||
msgs.extend(['{:>7}'.format('Rx/s'), ' {:<7}'.format('Tx/s')])
|
||||
|
||||
if 'ports' not in self.disable_stats:
|
||||
msgs.extend('{:16}'.format('Ports'))
|
||||
|
||||
if 'command' not in self.disable_stats:
|
||||
msgs.append(' {:8}'.format('Command'))
|
||||
|
||||
|
|
@ -473,6 +479,15 @@ class PluginModel(GlancesPluginModel):
|
|||
|
||||
return build_with_this_args
|
||||
|
||||
def build_ports(self, ret, container):
|
||||
if container['ports'] is not None and container['ports'] != '':
|
||||
msg = '{:16}'.format(container['ports'])
|
||||
else:
|
||||
msg = '{:16}'.format('_')
|
||||
ret.append(self.curse_add_line(msg, splittable=True))
|
||||
|
||||
return ret
|
||||
|
||||
def build_cmd_line(self, ret, container):
|
||||
if container['command'] is not None:
|
||||
msg = ' {}'.format(container['command'])
|
||||
|
|
@ -529,6 +544,8 @@ class PluginModel(GlancesPluginModel):
|
|||
steps.append(self.build_io_line)
|
||||
if 'networkio' not in self.disable_stats:
|
||||
steps.append(self.build_net_line(args))
|
||||
if 'ports' not in self.disable_stats:
|
||||
steps.append(self.build_ports)
|
||||
if 'command' not in self.disable_stats:
|
||||
steps.append(self.build_cmd_line)
|
||||
|
||||
|
|
|
|||
|
|
@ -312,6 +312,7 @@ class DockerExtension:
|
|||
'memory_percent': None,
|
||||
'network_rx': None,
|
||||
'network_tx': None,
|
||||
'ports': '',
|
||||
'uptime': None,
|
||||
}
|
||||
|
||||
|
|
@ -356,4 +357,8 @@ class DockerExtension:
|
|||
# Manage special chars in command (see issue#2733)
|
||||
stats['command'] = replace_special_chars(' '.join(stats['command']))
|
||||
|
||||
# Manage ports (see iisue#2054)
|
||||
if hasattr(container, 'ports'):
|
||||
stats['ports'] = ','.join([f'{container.ports[cp][0]["HostPort"]}->{cp}' for cp in container.ports])
|
||||
|
||||
return stats
|
||||
|
|
|
|||
|
|
@ -364,6 +364,7 @@ class PodmanExtension:
|
|||
'memory_percent': None,
|
||||
'network_rx': None,
|
||||
'network_tx': None,
|
||||
'ports': '',
|
||||
'uptime': None,
|
||||
}
|
||||
|
||||
|
|
@ -394,4 +395,8 @@ class PodmanExtension:
|
|||
# Manage special chars in command (see issue#2733)
|
||||
stats['command'] = replace_special_chars(' '.join(stats['command']))
|
||||
|
||||
# Manage ports (see iisue#2054)
|
||||
if hasattr(container, 'ports'):
|
||||
stats['ports'] = ','.join([f'{container.ports[cp][0]["HostPort"]}->{cp}' for cp in container.ports])
|
||||
|
||||
return stats
|
||||
|
|
|
|||
Loading…
Reference in New Issue