Skip to content

fix(network): read the hide_threshold_bytes the plugin documents - #3726

Merged
nicolargo merged 1 commit into
nicolargo:developfrom
ntdatt812:fix/network-hide-threshold-bytes
Sep 10, 2026
Merged

nicolargo merged 1 commit into
nicolargo:developfrom
ntdatt812:fix/network-hide-threshold-bytes

Conversation

@ntdatt812

Copy link
Copy Markdown
Contributor

The bug

hide_threshold_bytes is offered to users under [network] in two places:

conf/glances.conf

# 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 or equal than this value
#hide_threshold_bytes=0

docs/aoa/network.rst

[network]
hide_zero=True
hide_threshold_bytes=0

NetworkPlugin.__init__() never read it. diskio has read it since the option was introduced; network was left out:

# glances/plugins/diskio/__init__.py
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)

# glances/plugins/network/__init__.py
self.hide_zero = config.get_bool_value(self.plugin_name, 'hide_zero', default=False)

So the attribute stayed at the base-class default of 0 whatever the user wrote. Nothing reports it: hide_zero keeps working, it simply never applies the threshold, and an interface carrying a trickle of background traffic is shown when the user asked for it to be hidden.

The change

Read it beside hide_zero, exactly as diskio does. Two lines, no new behaviour of its own.

Tests

tests/test_network_hide_threshold.py, 5 tests. The wiring assertion alone would be weak, so the boundary is also read back out of the views dict: with hide_threshold_bytes=1024, an interface at 524 B/s stays hidden and one at 2048 B/s is revealed. The last test pins that the unconfigured default of 0 still reveals that same 524 B/s trickle, so this does not quietly change anyone's current behaviour.

Mutation — delete the added get_int_value line: 2 fail, the wiring test and the "below the threshold stays hidden" behavioural test.

tests/test_plugin_network.py and tests/test_lazy_views.py — 45 passed. ruff check and ruff format --check clean.

Independent of #3725, which fixes the comparison this threshold is used in; either can go first.

Both the reference configuration and docs/aoa/network.rst offer the option
under [network]:

    [network]
    hide_zero=True
    hide_threshold_bytes=0

but NetworkPlugin never read it, so it stayed at the base class default of
0 whatever the user wrote. diskio has read it since the option was added;
network was left out.

Nothing reports an option a plugin ignores: hide_zero keeps working, it
just never applies the threshold, so an interface carrying a trickle of
background traffic is shown when the user asked for it to be hidden.

Read it beside hide_zero, exactly as diskio does.
@nicolargo nicolargo added the bug label Sep 10, 2026
@nicolargo nicolargo added this to the Glances 4.5.7 milestone Sep 10, 2026
@nicolargo
nicolargo merged commit 7a6f5ba into nicolargo:develop Sep 10, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants