plugin_interface

Domain-specific plugin interface for system monitoring

MonitorPlugin

Abstract base class for hardware monitoring plugins. Implementations provide platform-specific logic to gather system statistics.

Planned Implementations:

Plugin Library Platform
cjm-system-monitor-nvidia nvitop / pynvml NVIDIA GPUs
cjm-system-monitor-amd rocm-smi AMD GPUs
cjm-system-monitor-cpu psutil CPU-only systems

Integration with PluginManager:

# Register as system monitor for resource scheduling
manager.register_system_monitor("sys-mon-nvidia")

# Scheduler will call execute() to get fresh stats before each plugin execution

source

MonitorPlugin


def MonitorPlugin(
    args:VAR_POSITIONAL, kwargs:VAR_KEYWORD
):

Abstract base class for hardware monitoring plugins.

Implementation Guide

When implementing a MonitorPlugin:

  1. execute() should handle at least the "get_system_status" command
  2. Return values should be SystemStats(...).to_dict() for JSON compatibility
  3. The plugin runs in its own isolated environment (can have specific deps like nvitop)
from cjm_infra_plugin_system.plugin_interface import MonitorPlugin
from cjm_infra_plugin_system.core import SystemStats

class NvidiaMonitorPlugin(MonitorPlugin):
    @property
    def name(self) -> str:
        return "sys-mon-nvidia"
    
    @property
    def version(self) -> str:
        return "1.0.0"
    
    def execute(self, command: str = "get_system_status", **kwargs) -> dict:
        if command == "get_system_status":
            # Gather stats using nvitop/pynvml
            stats = SystemStats(
                gpu_type="NVIDIA",
                gpu_free_memory_mb=...,
                # ... other fields
            )
            return stats.to_dict()
        raise ValueError(f"Unknown command: {command}")