Repository navigation
fix(quicklook): colour each --percpu bar by that core's own load - #3716
Merged
nicolargo merged 1 commit intoSep 10, 2026
Merged
Conversation
Both interfaces drew every per-core bar with the aggregate CPU style:
`_msg_create_line` read `views['cpu']['decoration']` for every row, and
plugin-quicklook.vue called `getDecoration('cpu')` inside the percpu loop.
A core pegged at 100% among idle ones was therefore painted with the colour
of the average, which is the one number that cannot show it.
update_views now publishes `views['percpu_decoration']`: a style per core,
plus 'other' for the row that averages the cores neither interface shows.
Both interfaces read it, so they agree.
The styles are computed from the plugin's own quicklook_cpu_* limits rather
than through get_alert(), because get_alert() also records a threshold that
glances.events_list reads and can run a configured action, and both are keyed
by the stat name alone. Every core shares 'quicklook_cpu' with the aggregate,
so a per-core call would leave the last core as the value those two see.
Also drops a duplicated `msg = msg =` assignment on a line already touched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
--percpumode the quicklook bars are per core, but their colour was not: every bar was drawn with the aggregate CPU style._msg_create_linereadsself.get_views(key=key, option='decoration'), andkeyis'cpu'for every row_msg_per_cpuemits.plugin-quicklook.vuecallsgetDecoration('cpu')inside thev-foroverpercpus.So on a box where one core is pegged at 100% and the rest are idle, that core's bar is painted with the colour of the average — the one number that cannot show it. The
cpu_careful/warning/criticallimits are configured and correct; nothing reads them per core.The change
update_viewsnow publishesviews['percpu_decoration'], a style percpu_numberplus'other'for the row that averages the cores neither interface displays (CPU*in curses,xin the WebUI). Both interfaces read that one map, so they agree by construction rather than by both getting it right separately. The WebUI falls back to the old aggregate style when the key is absent, so an older server does not break a newer page.The styles come from the plugin's own
quicklook_cpu_*limits directly rather than throughget_alert(). That is deliberate:get_alert()also callsmanage_threshold, which writesglances_thresholds[stat_name]thatglances/events_list.py:153reads, andmanage_action, which can run a configured[quicklook]command. Both are keyed by the stat name alone, and every core sharesquicklook_cpuwith the aggregate — so running the cores throughget_alert()would leave whichever core went last as the value the event list and any action see._decoration_for_percentis the same threshold ladder with none of that.One unrelated token:
msg = msg = f'{key.upper():3}* 'on a line the change already touches loses its duplicated assignment.Verification
pytest tests/test_plugin_quicklook.pyis 22 passed;tests/test_core.py tests/test_glances_curses.py tests/test_lazy_views.pyis 63 passed, 6 skipped.ruff checkandruff format --checkare clean on both changed Python files.Each claim was checked by breaking it, and each mutation fails only the test that owns it:
_msg_create_lineback to the aggregate lookuptest_the_styles_reach_the_curses_barsonlystats['cpu']instead of each core'stotal_decoration_for_percentreplaced byget_alert()test_scanning_the_cores_does_not_move_the_global_thresholdonlyThe first is the one that matters: without it the map is correct and unread, and every other test still passes.
The summary-row test picks values where the row disagrees with both of the things it could have borrowed — four cores at 95% and two at 60% give
CRITICALbars, aWARNINGaggregate (83%), and aCAREFULrow.I have no Linux box to hand for the curses rendering itself; the assertions above are on the message list
msg_cursebuilds, not on the terminal output.