Resource Monitoring Schema
This schema defines configuration options for real-time system resource monitoring. It’s designed to work with the cjm-fasthtml-settings library for automatic UI generation.
# Example: Accessing schema properties
print (f"Schema name: { RESOURCE_MONITOR_SCHEMA['name' ]} " )
print (f"Schema title: { RESOURCE_MONITOR_SCHEMA['title' ]} " )
print (f" \n Default intervals:" )
print (f" CPU: { RESOURCE_MONITOR_SCHEMA['properties' ]['cpu_interval' ]['default' ]} s" )
print (f" Memory: { RESOURCE_MONITOR_SCHEMA['properties' ]['memory_interval' ]['default' ]} s" )
print (f" GPU: { RESOURCE_MONITOR_SCHEMA['properties' ]['gpu_interval' ]['default' ]} s" )
Schema name: resource-monitoring
Schema title: Resource Monitor Configuration
Default intervals:
CPU: 2s
Memory: 3s
GPU: 5s
Last Update Tracking
Track last update times for each monitoring component. This is runtime state, not part of the configuration.
SSE Configuration
Configuration for Server-Sent Events (SSE) streaming. These settings are not exposed in the UI but can be adjusted programmatically.
# Example: Using the last update times
import time
# Simulate checking if an update is needed
cpu_interval = RESOURCE_MONITOR_SCHEMA['properties' ]['cpu_interval' ]['default' ]
current_time = time.time()
if current_time - LAST_UPDATE_TIMES['cpu' ] >= cpu_interval:
print ("CPU update needed!" )
LAST_UPDATE_TIMES['cpu' ] = current_time
else :
print ("CPU update not yet needed" )
print (f" \n SSE queue size: { SSE_CONFIG['max_queue_size' ]} " )
CPU update needed!
SSE queue size: 100