Files
sammykumar-ComfyUI-SwissArm…/tests/test_resource_monitor.py
T
Sammy Kumar 3fde3f99cf feat(monitor): add resource monitor service and API endpoints for hardware monitoring
feat(monitor): initialize resource monitor service in __init__.py and register API routes
chore(monitor): create utility modules for hardware and GPU information handling

feat(gpu_info.py): add GPU information collector to monitor VRAM, utilization, and temperature

This new module collects GPU metrics using pynvml and torch, providing detailed information about available GPUs and their performance. It enhances monitoring capabilities for applications utilizing GPU resources.

feat(monitoring): add hardware information collector and monitoring service to gather and broadcast system metrics

- Introduce `hardware_info.py` to collect CPU, RAM, and disk usage metrics.
- Implement `monitor_service.py` to periodically collect and broadcast hardware metrics.
- Update `requirements.txt` to include necessary dependencies: psutil, pynvml, and py-cpuinfo.

feat(tests): add test script for resource monitor backend to verify hardware monitoring functionality
2025-11-28 11:54:15 -06:00

59 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""
Test script for resource monitor backend
Run this to verify hardware monitoring is working
"""
import sys
import os
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nodes.utils.resource_monitor import HardwareInfo, GPUInfo, MonitorService
import json
def test_hardware_info():
"""Test hardware information collection"""
print("\n=== Testing Hardware Info ===")
hw = HardwareInfo()
status = hw.get_full_status()
print(json.dumps(status, indent=2, default=str))
def test_gpu_info():
"""Test GPU information collection"""
print("\n=== Testing GPU Info ===")
gpu = GPUInfo()
status = gpu.get_full_status()
print(json.dumps(status, indent=2, default=str))
def test_monitor_service():
"""Test monitor service (without actual server)"""
print("\n=== Testing Monitor Service ===")
# Create service without server (for testing only)
service = MonitorService(server=None, interval=2.0)
# Get current status
status = service.get_current_status()
print(json.dumps(status, indent=2, default=str))
print("\n=== Test GPU Device 0 ===")
device_info = service.get_gpu_device_info(0)
print(json.dumps(device_info, indent=2, default=str))
if __name__ == "__main__":
try:
test_hardware_info()
test_gpu_info()
test_monitor_service()
print("\n✅ All tests completed successfully!")
except Exception as e:
print(f"\n❌ Test failed: {e}")
import traceback
traceback.print_exc()
sys.exit(1)