diff --git a/conf/glances.conf b/conf/glances.conf index 6393a11ffd32bc2abc337d913082f6d5d4a85083..587a2b26dd23a0f3492272ca198bb22ceef7ec0b 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -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 diff --git a/docs/aoa/docker.rst b/docs/aoa/docker.rst index 0fb440ffb7e43d38c55637945954495e5a35bf57..c21dc8506e8277ac3a3e7b2801395c7a080bcda6 100644 --- a/docs/aoa/docker.rst +++ b/docs/aoa/docker.rst @@ -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 %) diff --git a/docs/man/glances.1 b/docs/man/glances.1 index 170620fcd2bb570bc9818dd89c26939acd15a94d..e20960cbd4e498451aa7e7c6647c793ad69dd2f1 100644 --- a/docs/man/glances.1 +++ b/docs/man/glances.1 @@ -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 diff --git a/glances/plugins/glances_docker.py b/glances/plugins/glances_docker.py index 14f35af8165be45cfc6f193fe125e4e071c82ac5..82dd1693428adc9fa6ac7f474abf159fa7ba4296 100644 --- a/glances/plugins/glances_docker.py +++ b/glances/plugins/glances_docker.py @@ -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 diff --git a/glances/plugins/glances_plugin.py b/glances/plugins/glances_plugin.py index 936db58c363a9b20c7a1ec36e6f463eaeb674200..e092ff058a9d3373dfc80e8d4b97f05e918f1f72 100644 --- a/glances/plugins/glances_plugin.py +++ b/glances/plugins/glances_plugin.py @@ -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):