mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-03 23:26:01 +03:00
Filter docker containers #1748
This commit is contained in:
commit
00357bd4b3
@ -327,6 +327,12 @@ port_default_gateway=True
|
||||
|
||||
[docker]
|
||||
disable=False
|
||||
# Only show specific containers (comma separeted list of container name or regular expression)
|
||||
# Comment this line to display all containers (default configuration)
|
||||
#show=telegraf
|
||||
# Hide some containers (comma separeted list of container name or regular expression)
|
||||
# Comment this line to display all containers (default configuration)
|
||||
#hide=telegraf
|
||||
# Define the maximum docker size name (default is 20 chars)
|
||||
max_name_size=20
|
||||
#cpu_careful=50
|
||||
|
@ -21,6 +21,10 @@ under the ``[docker]`` section:
|
||||
|
||||
[docker]
|
||||
disable=False
|
||||
# Only show specific containers (comma separeted list of container name or regular expression)
|
||||
show=thiscontainer,andthisone,andthoseones.*
|
||||
# Hide some containers (comma separeted list of container name or regular expression)
|
||||
hide=donotshowthisone,andthose.*
|
||||
# Define the maximum docker size name (default is 20 chars)
|
||||
max_name_size=20
|
||||
# Global containers' thresholds for CPU and MEM (in %)
|
||||
|
@ -1,6 +1,6 @@
|
||||
.\" Man page generated from reStructuredText.
|
||||
.
|
||||
.TH "GLANCES" "1" "Nov 07, 2020" "3.1.6_b1" "Glances"
|
||||
.TH "GLANCES" "1" "Nov 15, 2020" "3.1.6_b1" "Glances"
|
||||
.SH NAME
|
||||
glances \- An eye on your system
|
||||
.
|
||||
@ -395,9 +395,6 @@ Sort processes by I/O rate
|
||||
Show/hide IP module
|
||||
.TP
|
||||
.B \fBk\fP
|
||||
Kill selected process (only in curses/standalone mode)
|
||||
.TP
|
||||
.B \fBK\fP
|
||||
Show/hide TCP connections
|
||||
.TP
|
||||
.B \fBl\fP
|
||||
@ -483,12 +480,6 @@ Enable/disable mean GPU mode
|
||||
.B \fB/\fP
|
||||
Switch between process command line or command name
|
||||
.TP
|
||||
.B \fBUP\fP
|
||||
Up in the processes list
|
||||
.TP
|
||||
.B \fBDOWN\fP
|
||||
Down in the processes list
|
||||
.TP
|
||||
.B \fBF5\fP
|
||||
Refresh stats in curses user interface
|
||||
.UNINDENT
|
||||
|
@ -210,6 +210,14 @@ class Plugin(GlancesPlugin):
|
||||
# Get stats for all containers
|
||||
stats['containers'] = []
|
||||
for container in containers:
|
||||
# Only show specific containers
|
||||
if not self.is_show(nativestr(container.name)):
|
||||
continue
|
||||
|
||||
# Do not take hiden container into account
|
||||
if self.is_hide(nativestr(container.name)):
|
||||
continue
|
||||
|
||||
# Init the stats for the current container
|
||||
container_stats = {}
|
||||
# The key is the container name and not the Id
|
||||
|
@ -752,6 +752,21 @@ class GlancesPlugin(object):
|
||||
except KeyError:
|
||||
return default
|
||||
|
||||
def is_show(self, value, header=""):
|
||||
"""Return True if the value is in the show configuration list.
|
||||
If the show value is empty, return True (show by default)
|
||||
|
||||
The show configuration list is defined in the glances.conf file.
|
||||
It is a comma separed list of regexp.
|
||||
Example for diskio:
|
||||
show=sda.*
|
||||
"""
|
||||
# @TODO: possible optimisation: create a re.compile list
|
||||
if self.get_conf_value('show', header=header) == []:
|
||||
return True
|
||||
else:
|
||||
return any(j for j in [re.match(i, value) for i in self.get_conf_value('show', header=header)])
|
||||
|
||||
def is_hide(self, value, header=""):
|
||||
"""Return True if the value is in the hide configuration list.
|
||||
|
||||
@ -760,9 +775,7 @@ class GlancesPlugin(object):
|
||||
Example for diskio:
|
||||
hide=sda2,sda5,loop.*
|
||||
"""
|
||||
# TODO: possible optimisation: create a re.compile list
|
||||
# Old version (see issue #1691)
|
||||
#return not all(j is None for j in [re.match(i, value.lower()) for i in self.get_conf_value('hide', header=header)])
|
||||
# @TODO: possible optimisation: create a re.compile list
|
||||
return any(j for j in [re.match(i, value) for i in self.get_conf_value('hide', header=header)])
|
||||
|
||||
def has_alias(self, header):
|
||||
|
Loading…
Reference in New Issue
Block a user