Introduce the backend pieces for brain memory ingestion, routing, and system telemetry so the new knowledge workflows can project data into a brain view. The supporting tests lock in the new behavior and keep the expanded backend surface stable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
832 B
Python
28 lines
832 B
Python
from datetime import datetime, UTC
|
|
|
|
try:
|
|
import psutil
|
|
except ModuleNotFoundError: # pragma: no cover - optional runtime dependency fallback
|
|
psutil = None
|
|
|
|
|
|
class SystemService:
|
|
def get_status(self) -> dict:
|
|
if psutil is None:
|
|
return {
|
|
'cpu_percent': 0.0,
|
|
'memory_percent': 0.0,
|
|
'disk_percent': 0.0,
|
|
'timestamp': datetime.now(UTC).isoformat(),
|
|
}
|
|
|
|
cpu_percent = psutil.cpu_percent(interval=None)
|
|
memory = psutil.virtual_memory()
|
|
disk = psutil.disk_usage('/')
|
|
return {
|
|
'cpu_percent': round(cpu_percent, 1),
|
|
'memory_percent': round(memory.percent, 1),
|
|
'disk_percent': round(disk.percent, 1),
|
|
'timestamp': datetime.now(UTC).isoformat(),
|
|
}
|