Create a Show option in the configuration file to only show some stats #2052

pull/2064/head
nicolargo 2022-05-22 16:27:46 +02:00
parent feed48aa8d
commit 4d50e8cb57
15 changed files with 985 additions and 952 deletions

View File

@ -158,6 +158,8 @@ tx_warning=80
tx_critical=90
# Define the list of hidden network interfaces (comma-separated regexp)
#hide=docker.*,lo
# Define the list of wireless network interfaces to be show (comma-separated)
#show=docker.*
# WLAN 0 alias
#wlan0_alias=Wireless
# It is possible to overwrite the bitrate thresholds per interface
@ -187,6 +189,8 @@ nf_conntrack_percent_critical=90
disable=True
# Define the list of hidden wireless network interfaces (comma-separated regexp)
hide=lo,docker.*
# Define the list of wireless network interfaces to be show (comma-separated)
#show=docker.*
# Define SIGNAL thresholds in db (lower is better...)
# Based on: http://serverfault.com/questions/501025/industry-standard-for-minimum-wifi-signal-strength
careful=-65
@ -198,6 +202,8 @@ disable=False
# Define the list of hidden disks (comma-separated regexp)
#hide=sda2,sda5,loop.*
hide=loop.*,/dev/loop*
# Define the list of disks to be show (comma-separated)
#show=sda.*
# Alias for sda1
#sda1_alias=InternalDisk
@ -205,6 +211,8 @@ hide=loop.*,/dev/loop*
disable=False
# Define the list of hidden file system (comma-separated regexp)
hide=/boot.*,/snap.*
# Define the list of file system to be show (comma-separated)
#show=/,/srv
# Define filesystem space thresholds in %
# Default values if not defined: 50/70/90
# It is also possible to define per mount point value

View File

@ -17,6 +17,7 @@ There is no alert on this information.
It's possible to define:
- a list of disk to show (white list)
- a list of disks to hide
- aliases for disk name
@ -29,3 +30,10 @@ and the specific ``sda5`` partition:
[diskio]
hide=sda5,loop.*
or another example:
.. code-block:: ini
[diskio]
show=sda.*

View File

@ -25,6 +25,8 @@ under the ``[docker]`` section:
show=thiscontainer,andthisone,andthoseones.*
# Hide some containers (comma separeted list of container name or regular expression)
hide=donotshowthisone,andthose.*
# Show only specific containers (comma separeted list of container name or regular expression)
#show=showthisone,andthose.*
# Define the maximum docker size name (default is 20 chars)
max_name_size=20
# Global containers' thresholds for CPU and MEM (in %)

View File

@ -46,9 +46,10 @@ To hide all mount points starting with /boot and /snap:
Filtering are also applied on device name (Glances 3.1.4 or higher).
Example to hide all /dev/sdb mount points:
It is also possible to configure a white list of devices to display:
Example to only show /dev/sdb mount points:
.. code-block:: ini
[fs]
hide=/dev/sdb.*
show=/dev/sdb.*

View File

@ -39,6 +39,8 @@ virtual docker interface (docker0, docker1, ...):
tx_critical=90
# Define the list of hidden network interfaces (comma-separated regexp)
hide=docker.*,lo
# Define the list of network interfaces to show (comma-separated regexp)
#show=eth0,eth1
# WLAN 0 alias
wlan0_alias=Wireless IF
# It is possible to overwrite the bitrate thresholds per interface

View File

@ -27,6 +27,7 @@ hide the loopback interface (lo) and all the virtual docker interfaces:
[wifi]
hide=lo,docker.*
#show=wlp2s0
# Define SIGNAL thresholds in dBm (lower is better...)
careful=-65
warning=-75

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,5 @@
.\" Man page generated from reStructuredText.
.
.TH "GLANCES" "1" "Apr 10, 2022" "3.2.5" "Glances"
.SH NAME
glances \- An eye on your system
.
.nr rst2man-indent-level 0
.
@ -30,6 +27,9 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "GLANCES" "1" "May 22, 2022" "3.2.6_beta01" "Glances"
.SH NAME
glances \- An eye on your system
.SH SYNOPSIS
.sp
\fBglances\fP [OPTIONS]

View File

@ -98,8 +98,9 @@ class Plugin(GlancesPlugin):
if self.args is not None and not self.args.diskio_show_ramfs and disk.startswith('ram'):
continue
# Do not take hide disk into account
if self.is_hide(disk):
# Shall we display the stats ?
logger.info("diskio: %s => %s", disk, self.is_display(disk))
if not self.is_display(disk):
continue
# Compute count and bit rate

View File

@ -236,12 +236,8 @@ 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 hidden container into account
if self.is_hide(nativestr(container.name)):
# Should we display the container stats ?
if not self.is_display(nativestr(container.name)):
continue
# Init the stats for the current container

View File

@ -116,10 +116,10 @@ class Plugin(GlancesPlugin):
# Loop over fs
for fs in fs_stat:
# Do not take hidden file system into account
# Also check device name (see issue #1606)
if self.is_hide(fs.mountpoint) or self.is_hide(fs.device):
# Shall we display the stats ?
if not self.is_display(fs.mountpoint):
continue
# Grab the disk usage
try:
fs_usage = psutil.disk_usage(fs.mountpoint)

View File

@ -156,7 +156,7 @@ class Plugin(GlancesPlugin):
for net in network_new:
# Do not take hidden interface into account
# or KeyError: 'eth0' when interface is not connected #1348
if self.is_hide(net) or net not in net_status:
if not self.is_display(net) or net not in net_status:
continue
try:
cumulative_rx = network_new[net].bytes_recv
@ -217,7 +217,7 @@ class Plugin(GlancesPlugin):
for net in network_new:
# Do not take hidden interface into account
if self.is_hide(net):
if not self.is_display(net):
continue
try:

View File

@ -883,10 +883,7 @@ class GlancesPlugin(object):
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)])
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.
@ -899,6 +896,14 @@ class GlancesPlugin(object):
# @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 is_display(self, value, header=""):
"""Return True if the value should be displayed in the UI
"""
if self.get_conf_value('show', header=header) != []:
return self.is_show(value, header=header)
else:
return not self.is_hide(value, header=header)
def has_alias(self, header):
"""Return the alias name for the relative header it it exists otherwise None."""
try:

View File

@ -131,7 +131,7 @@ class Plugin(GlancesPlugin):
self.stats = self.get_init_value()
for stat in stats:
# Do not take hide stat into account
if self.is_hide(stat["label"].lower()):
if not self.is_display(stat["label"].lower()):
continue
# Set the alias for each stat
alias = self.has_alias(stat["label"].lower())

View File

@ -91,7 +91,7 @@ class Plugin(GlancesPlugin):
for net in net_io_counters:
# Do not take hidden interface into account
if self.is_hide(net):
if not self.is_display(net):
continue
# Grab the stats using the Wifi Python lib