Merge pull request #2985 from uoguelph-engg4450/Lukas-Dev

Implement Improve hide_zero option #2958
This commit is contained in:
Nicolas Hennion 2024-10-23 21:07:30 +02:00 committed by GitHub
commit 88a804b57b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 3 deletions

View File

@ -222,6 +222,8 @@ hide_no_up=True
hide_no_ip=True
# Set hide_zero to True to automatically hide interface with no traffic
hide_zero=False
# Set hide_threshold_bytes to an integer value to automatically hide interface with traffic less than this value
hide_threshold_bytes=0
# It is possible to overwrite the bitrate thresholds per interface
# WLAN 0 Default limits (in bits per second aka bps) for interface bitrate
#wlan0_rx_careful=4000000
@ -284,6 +286,8 @@ disable=False
hide=loop.*,/dev/loop.*
# Set hide_zero to True to automatically hide disk with no read/write
hide_zero=False
# Set hide_threshold_bytes to an integer value to automatically hide disk with read/write less than this value
hide_threshold_bytes=0
# Define the list of disks to be show (comma-separated)
#show=sda.*
# Alias for sda1 and sdb1

View File

@ -13,7 +13,7 @@ check_update=False
# Default is 1200 values (~1h with the default refresh rate)
history_size=1200
# Set the way Glances should display the date (default is %Y-%m-%d %H:%M:%S %Z)
#strftime_format=%Y-%m-%d %H:%M:%S %Z
# strftime_format=%Y-%m-%d %H:%M:%S %Z
# Define external directory for loading additional plugins
# The layout follows the glances standard for plugin definitions
#plugin_dir=/home/user/dev/plugins
@ -222,6 +222,8 @@ hide_no_up=True
hide_no_ip=True
# Set hide_zero to True to automatically hide interface with no traffic
hide_zero=False
# Set hide_threshold_bytes to an integer value to automatically hide interface with traffic less than this value
hide_threshold_bytes=0
# It is possible to overwrite the bitrate thresholds per interface
# WLAN 0 Default limits (in bits per second aka bps) for interface bitrate
#wlan0_rx_careful=4000000
@ -284,6 +286,8 @@ disable=False
hide=loop.*,/dev/loop.*
# Set hide_zero to True to automatically hide disk with no read/write
hide_zero=False
# Set hide_threshold_bytes to an integer value to automatically hide disk with read/write less than this value
hide_threshold_bytes=0
# Define the list of disks to be show (comma-separated)
#show=sda.*
# Alias for sda1 and sdb1

View File

@ -73,8 +73,10 @@ class PluginModel(GlancesPluginModel):
# Hide stats if it has never been != 0
if config is not None:
self.hide_zero = config.get_bool_value(self.plugin_name, 'hide_zero', default=False)
self.hide_threshold_bytes = config.get_int_value(self.plugin_name, 'hide_threshold_bytes', default=0)
else:
self.hide_zero = False
self.hide_threshold_bytes = 0
self.hide_zero_fields = ['read_bytes_rate_per_sec', 'write_bytes_rate_per_sec']
# Force a first update because we need two updates to have the first stat

View File

@ -110,6 +110,8 @@ class GlancesPluginModel:
# Hide stats if all the hide_zero_fields has never been != 0
# Default is False, always display stats
self.hide_zero = False
# The threshold needed to display a value if hide_zero is true. Only hide a value if it is less than hide_threshold_bytes.
self.hide_threshold_bytes = 0
self.hide_zero_fields = []
# Set the initial refresh time to display stats the first time
@ -463,7 +465,7 @@ class GlancesPluginModel:
value['hidden'] = False
elif key in self.views and field in self.views[key] and 'hidden' in self.views[key][field]:
value['hidden'] = self.views[key][field]['hidden']
if field in self.hide_zero_fields and i[field] != 0:
if field in self.hide_zero_fields and i[field] >= self.hide_threshold_bytes:
value['hidden'] = False
else:
value['hidden'] = field in self.hide_zero_fields
@ -485,7 +487,7 @@ class GlancesPluginModel:
value['hidden'] = False
elif field in self.views and 'hidden' in self.views[field]:
value['hidden'] = self.views[field]['hidden']
if field in self.hide_zero_fields and self.get_raw()[field] != 0:
if field in self.hide_zero_fields and self.get_raw()[field] >= self.hide_threshold_bytes:
value['hidden'] = False
else:
value['hidden'] = field in self.hide_zero_fields