diff --git a/CLAUDE.md b/CLAUDE.md index 02f4470..a83b869 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,6 +6,53 @@ A high-performance Rust-based TUI dashboard for monitoring CMTEC infrastructure. ## Implementation Strategy +### Next Phase: Systemd Collector Optimization (Based on TODO.md) + +**Current Status**: Reverted to working baseline (commit 245e546) after optimization broke service discovery. + +**Planned Implementation Steps** (step-by-step to avoid breaking functionality): + +**Phase 1: Exact Name Filtering** +- Replace `contains()` matching with exact name matching for service filters +- Change `service_name.contains(pattern) || pattern.contains(service_name)` to `service_name == pattern` +- Test: Ensure cmbox remains visible with exact service names in config +- Commit and test after each change + +**Phase 2: Remove User Service Collection** +- Remove all `sudo -u` systemctl commands for user services +- Remove user_unit_files_output and user_units_output logic +- Keep only system service discovery via `systemctl list-units --type=service` +- Test: Verify system services still discovered correctly + +**Phase 3: Add Wildcard Support** +- Implement glob pattern matching for service filters +- Support patterns like "nginx*" to match "nginx", "nginx-config-reload", etc. +- Use fnmatch or similar for wildcard expansion +- Test: Verify patterns work as expected + +**Phase 4: Optimize systemctl Calls** +- Cache service status information during discovery +- Eliminate redundant `systemctl is-active` and `systemctl show` calls per service +- Parse status from `systemctl list-units` output directly +- Test: Ensure performance improvement without functionality loss + +**Phase 5: Include-Only Discovery** +- Remove auto-discovery of all services +- Only check services explicitly listed in service_name_filters +- Skip systemctl discovery entirely, use configured list directly +- Test: Verify only configured services are monitored + +**Critical Requirements:** +- Each phase must be tested independently +- cmbox must remain visible in dashboard after each change +- No functionality regressions allowed +- Commit each phase separately with descriptive messages + +**Rollback Strategy:** +- If any phase breaks functionality, immediately revert that specific commit +- Do not attempt to "fix forward" - revert and redesign the problematic step +- Each phase should be atomic and independently revertible + ## Core Architecture Principles - CRITICAL ### Individual Metrics Philosophy diff --git a/TODO.md b/TODO.md index 40d085f..dc5e7b2 100644 --- a/TODO.md +++ b/TODO.md @@ -1,8 +1,17 @@ # TODO -## Show logged in users (agent/dashboard) +## Systemd filtering (agent) + +- remove user systemd collection +- reduce number of systemctl call +- Cahnge so only services in include list are detected +- Filter on exact name +- Add support for "\*" in filtering + +## System panel (agent/dashboard) - Add support to show login users +- Add support to show timestamp/version for latest nixos rebuild ## Keyboard navigation and scrolling (dashboard)