提交 7c1e039e 编写于 作者: N nicolargo

Filter docker containers #1748

上级 bc0cf31a
......@@ -327,7 +327,11 @@ port_default_gateway=True
[docker]
disable=False
# Hide some containers (comma separeted list)
# 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
......
......@@ -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 %)
......
.\" 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,7 +210,11 @@ class Plugin(GlancesPlugin):
# Get stats for all containers
stats['containers'] = []
for container in containers:
# Do not take hide container into account
# 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
......
......@@ -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):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册