# plugin_interface


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## MonitorPlugin

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

**Planned Implementations:**

<table>
<thead>
<tr>
<th>Plugin</th>
<th>Library</th>
<th>Platform</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>cjm-system-monitor-nvidia</code></td>
<td><code>nvitop</code> / <code>pynvml</code></td>
<td>NVIDIA GPUs</td>
</tr>
<tr>
<td><code>cjm-system-monitor-amd</code></td>
<td><code>rocm-smi</code></td>
<td>AMD GPUs</td>
</tr>
<tr>
<td><code>cjm-system-monitor-cpu</code></td>
<td><code>psutil</code></td>
<td>CPU-only systems</td>
</tr>
</tbody>
</table>

**Integration with PluginManager:**

``` python
# 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
```

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-infra-plugin-system/blob/main/cjm_infra_plugin_system/plugin_interface.py#L17"
target="_blank" style="float:right; font-size:smaller">source</a>

### MonitorPlugin

``` python

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`)

``` python
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}")
```
