core

Core data structures for infrastructure monitoring

SystemStats

Standardized snapshot of system resources. This DTO is used by:

  • ResourceScheduler: Checks gpu_free_memory_mb and memory_available_mb against plugin requirements
  • Dashboard UIs: Displays resource usage via the details field
  • Logging/Metrics: Tracks resource utilization over time

The to_dict() method ensures compatibility with the JSON-based communication protocol.


source

SystemStats


def SystemStats(
    cpu_percent:float=0.0, memory_used_mb:float=0.0, memory_total_mb:float=0.0, memory_available_mb:float=0.0,
    gpu_type:str='None', gpu_free_memory_mb:float=0.0, gpu_total_memory_mb:float=0.0, gpu_used_memory_mb:float=0.0,
    gpu_load_percent:float=0.0, details:Dict=<factory>
)->None:

Standardized snapshot of system resources.

Example Usage

from cjm_infra_plugin_system.core import SystemStats

# Create stats snapshot
stats = SystemStats(
    cpu_percent=45.2,
    memory_used_mb=16384,
    memory_total_mb=32768,
    memory_available_mb=16384,
    gpu_type="NVIDIA",
    gpu_free_memory_mb=8192,
    gpu_total_memory_mb=24576,
    gpu_used_memory_mb=16384,
    gpu_load_percent=75.0,
    details={
        "gpu_0": {"name": "RTX 4090", "temp_c": 65},
        "gpu_1": {"name": "RTX 4090", "temp_c": 68}
    }
)

# Convert to dict for JSON transmission
stats_dict = stats.to_dict()