feat: show host metrics speedbar in monit dashboard - #6138
Open
ButchAnton wants to merge 1 commit into
Open
Conversation
pm2 status/ls already print a host metrics ("speedbar") line when
pm2:sysmonit is enabled, but pm2 monit/dashboard never showed it,
even though the same getSystemData data is available. This adds the
same line below the help bar in the dashboard, refreshed on its own
2s poll independent of the per-process 800ms refresh loop.
The bar only takes up space when there is data to show: layout
toggles between two fixed states (no speedbar vs. speedbar) so
metadata/custom metrics panels reclaim the space when pm2:sysmonit
is off, instead of leaving a permanent empty line.
While sizing the new layout, also fixes a pre-existing 1% overlap
between box4 and the metadata/custom metrics panels that clipped
their bottom border at certain terminal row counts even without this
change (heights are 25%/5% for both states now instead of 26%/6%).
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
What
pm2 status/pm2 lsalready print a "host metrics" line (CPU, RAM, disk, network, etc.) whenpm2:sysmonitis enabled, butpm2 monit/pm2 dashboardnever showed it, even though the samegetSystemDatadata is available there too. This adds the same line to the dashboard, directly below the existing help/shortcuts bar.Details
lib/API/Extra.js:dashboard()now also pollsgetSystemDataon its own 2s interval (independent of the existing 800ms per-processgetMonitorDatapoll, since host metrics are a daemon-wide snapshot, not per-process) and forwards the result toDashboard.refreshSystemData().lib/API/Dashboard.js:speedbarBoxwidget, hidden by default.Dashboard.refreshSystemData()renders the line (ported fromminiMonitBar()inlib/API/UX/pm2-ls.js, same thresholds/colors, just blessed content tags instead of chalk/ansis) and calls a newsetSpeedbarLayout()helper.setSpeedbarLayout()toggles between two fixed layouts so the bar only takes up space when there's actually data to show: whenpm2:sysmonitis off (or hasn't reported yet),metadataBox/metricsBox/box4sit exactly where they do today andspeedbarBoxis hidden - no permanent dead space. When data arrives,metadataBox/metricsBoxshrink slightly andbox4moves up to make room for the bar.screen.realloc()is called on each transition so blessed does a full repaint instead of leaving stale borders/content from the previous layout (its incremental diff render only marks cells dirty on content changes, not dimension changes).box4's stocktop: '95%', height: '6%'ends at 101%, one point past both the screen and pastmetadataBox/metricsBox's own bottom edge (70% + 26%= 96%). At certain terminal row counts (rounding-dependent, e.g. exactly 50 rows) that 1% overlap causesbox4to paint over the bottom border of the metadata/custom metrics panels, since it's appended after them. Both states now use 25%/5% instead of 26%/6%, which closes the gap everywhere rather than only at the row counts stock pm2's rounding happens to dodge it at.Testing
Manually verified against a scratch
PM2_HOMEin a tmux session at a few terminal sizes:pm2:sysmoniton: speedbar renders below the help line with correct data/colors, no border clipping.pm2:sysmonitoff: layout matches current stock pm2 exactly, no empty reserved line.Happy to add/adjust automated coverage if there's a preferred pattern for dashboard/blessed-UI tests in this repo - I didn't see existing ones to follow for
lib/API/Dashboard.js.Made with Cursor