Skip to content

Make load-average gauges use CPU thresholds, not fixed 70/100% - #98

Merged
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-67-6se35o
Aug 21, 2026
Merged

Make load-average gauges use CPU thresholds, not fixed 70/100%#98
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-67-6se35o

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Pull Request

📖 Description

packaging/pimonitor.example.yaml documents the thresholds section as driving "the load-average gauge scale, which uses the CPU thresholds relative to core count," but renderGauge() in internal/web/assets/app.js hardcoded cores × 0.7 / cores × 1.0 for the gauge's warn/crit color thresholds, ignoring the configured cpu_warn_percent / cpu_crit_percent.

This fixes the code to match the documented behavior instead of correcting the doc, since using the configured thresholds is more useful (and consistent with how the CPU usage bar already uses the same thresholds).

renderGauge() now takes warnPercent/critPercent parameters, and the three load-average gauge calls (gauge-load1/5/15) pass config.thresholds.cpu_warn_percent / cpu_crit_percent.

🎫 Issues

Closes #67

👩‍💻 Reviewer Notes

Pure frontend change in internal/web/assets/app.js; no Go API/behavior changes. Smoke test: open the dashboard, confirm the load-average gauges still render and change color at the expected thresholds (scaled by core count and cpu_warn_percent/cpu_crit_percent).

📑 Test Plan

Added internal/web/gauge_test.go, following this repo's existing pattern of Go tests that read the embedded app.js source and assert on it (see xss_test.go, dialog_test.go). It guards against the hardcoded 0.7/1.0 factors reappearing and asserts the load-gauge calls pass t.cpu_warn_percent/t.cpu_crit_percent.

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./... -race -cover — all packages pass
  • golangci-lint run — 0 issues

✅ Checklist

General

  • I have added/updated tests for my changes (go test ./... -race -cover passes locally).
  • go vet ./... and golangci-lint run are clean.
  • I have tested my changes.
  • I have read the CONTRIBUTING documentation and followed the project's code style guidelines.
  • I have updated ARCHITECTURE.md if this changes a documented design decision. (not applicable — no design decision changed, just a bug fix)

REST API / configuration / packaging

Not applicable — no REST API, config, or packaging changes.

⏭ Next Steps

None.

renderGauge() hardcoded 70% and 100% of core count as the gauge's
warn/crit thresholds, regardless of the configured cpu_warn_percent /
cpu_crit_percent. This contradicted the documented behavior in
packaging/pimonitor.example.yaml, which claims the load-average gauge
scale uses the CPU thresholds relative to core count.

renderGauge() now takes warnPercent/critPercent parameters, and the
three load-average gauge calls pass config.thresholds.cpu_warn_percent
/ cpu_crit_percent, matching the documented behavior and the CPU usage
bar's own use of the same thresholds.

Closes #67
@sonarqubecloud

Copy link
Copy Markdown

@LarsLaskowski
LarsLaskowski merged commit 709a5b9 into main Aug 21, 2026
5 checks passed
@LarsLaskowski
LarsLaskowski deleted the claude/issue-67-6se35o branch August 21, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: example config claims load gauges use the CPU thresholds; app.js hardcodes 70 %/100 % of core count

2 participants