1.6 KiB
1.6 KiB
Step 09: System Metrics
Prerequisites: step 07 (API), step 08 (layout).
Read README.md and 00-legacy-analysis.md first.
Goal
Port the legacy system page: CPU, RAM, disk, and repository size with min/max/avg aggregation.
Design
Create package de.hoennig.gittally.metrics:
SystemMetricsCollectorsampling every 60s (server profile only): CPU used/idle from/proc/statdeltas, RAM from/proc/meminfo, disk fromjava.nio.file.FileStore, repo size via periodicdu -sk(or a file walk) — throttle repo-size sampling (legacy randuevery cycle, which was expensive).- Keep running min/max/avg per metric since server start; persist aggregation state in the artifact root so restarts continue the series (legacy
system_state.dat, but as JSON). GET /api/systemreturning the current snapshot plus aggregates (legacysystem.jsonfields are the reference)./systemHTML view in the step 08 layout, polling/api/systemevery 60s with the same error-badge rules.
Out of Scope
- Alerting, historical time series, external monitoring integration.
- Windows/macOS support beyond graceful degradation (missing
/proc→ metric shows "n/a").
Tests
- Collector unit tests with fake
/procfile content (read paths injectable). - Aggregation math: min/max/avg over samples, persistence round-trip.
- Controller slice test for
/api/system. - Graceful degradation when a source is unreadable.
Acceptance Criteria
./gradlew ktlintFormatthen./gradlew buildis green./systemrenders live values on Linux (manual smoke test; document in this file).