Skip to content

feat: add System Monitor sensor plugin for hardware telemetry#4

Closed
luckyson113 wants to merge 6 commits intosrc/inputs/plugins/system_monitor.pyfrom
feat/system-monitor-sensor
Closed

feat: add System Monitor sensor plugin for hardware telemetry#4
luckyson113 wants to merge 6 commits intosrc/inputs/plugins/system_monitor.pyfrom
feat/system-monitor-sensor

Conversation

@luckyson113
Copy link
Copy Markdown
Owner

Overview

This PR introduces the SystemMonitorSensor to the OM1 sensor suite. This plugin allows the AI Agent to self-monitor its hardware health (CPU Load, RAM Usage, and Thermal status), which is essential for stability when deployed on edge devices like Raspberry Pi or Jetson.

Changes

  • New Plugin: Created src/inputs/plugins/system_monitor.py.
  • Architecture Compliance: Implemented SystemMonitorSensor inheriting correctly from Sensor[dict] (referencing src/inputs/base).
  • Core Implementation:
    • Implemented _listen_loop to yield metrics asynchronously every 2 seconds.
    • Implemented formatted_latest_buffer to allow the LLM/Fuser to read system status as context.
    • Implemented raw_to_text for JSON logging.
  • Reliability: Added mock_mode and robust exception handling (catching psutil specific errors) to ensure the agent doesn't crash on unsupported hardware (Docker/MacOS).
  • Code Quality: Fully compliant with Ruff and Black formatting standards (sorted imports, relative imports).

Testing

  • Linting: Passed ruff check . with strict import sorting (I001) and specific exception handling (BLE001).
  • Mock Mode: Verified that the sensor returns static data when mock_mode=True (safe for CI/CD).
  • Real Data: Verified integration with psutil to fetch real CPU/RAM metrics.

Impact

  • Adds a dependency on psutil (standard system monitoring library).
  • Low performance overhead (sampling interval set to 2.0s).

Additional Information

This implementation fixes previous import sorting issues by placing the file in the correct src/inputs/plugins directory and using relative imports (from ..base import Sensor) as per the project structure.

Implemented the SystemMonitorSensor in `src/inputs/plugins/system_monitor.py` to track hardware health.

Key changes:
- Inherits correctly from `Sensor[dict]` (inputs/base).
- Implements required abstract methods: `_listen_loop`, `formatted_latest_buffer`, and `raw_to_text`.
- Monitors CPU usage, Memory usage, and Temperature using `psutil`.
- Includes robust exception handling and Mock mode support for non-hardware environments.
- Complies with Ruff/Black formatting standards (sorted imports, relative imports).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant