mirror of
https://github.com/rightup/pyMC_Repeater.git
synced 2026-03-28 17:43:06 +01:00
add hardware statistics collection to StorageCollector and API endpoints
This commit is contained in:
@@ -64,6 +64,11 @@ class StorageCollector:
|
||||
self.disallowed_packet_types = set()
|
||||
else:
|
||||
self.disallowed_packet_types = set()
|
||||
|
||||
# Initialize hardware stats collector
|
||||
from .hardware_stats import HardwareStatsCollector
|
||||
self.hardware_stats = HardwareStatsCollector()
|
||||
logger.info("Hardware stats collector initialized")
|
||||
|
||||
def _get_live_stats(self) -> dict:
|
||||
"""Get live stats from RepeaterHandler"""
|
||||
@@ -228,3 +233,19 @@ class StorageCollector:
|
||||
|
||||
def delete_advert(self, advert_id: int) -> bool:
|
||||
return self.sqlite_handler.delete_advert(advert_id)
|
||||
|
||||
def get_hardware_stats(self) -> Optional[dict]:
|
||||
"""Get current hardware statistics"""
|
||||
try:
|
||||
return self.hardware_stats.get_stats()
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting hardware stats: {e}")
|
||||
return None
|
||||
|
||||
def get_hardware_processes(self) -> Optional[list]:
|
||||
"""Get current process summary"""
|
||||
try:
|
||||
return self.hardware_stats.get_processes_summary()
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting hardware processes: {e}")
|
||||
return None
|
||||
|
||||
@@ -249,8 +249,9 @@ class APIEndpoints:
|
||||
"""Get comprehensive hardware statistics"""
|
||||
try:
|
||||
# Get hardware stats from storage collector
|
||||
if hasattr(self.daemon_instance, 'storage_collector') and self.daemon_instance.storage_collector:
|
||||
stats = self.daemon_instance.storage_collector.get_hardware_stats()
|
||||
storage = self._get_storage()
|
||||
if storage:
|
||||
stats = storage.get_hardware_stats()
|
||||
if stats:
|
||||
return self._success(stats)
|
||||
else:
|
||||
@@ -267,8 +268,9 @@ class APIEndpoints:
|
||||
"""Get summary of top processes"""
|
||||
try:
|
||||
# Get process stats from storage collector
|
||||
if hasattr(self.daemon_instance, 'storage_collector') and self.daemon_instance.storage_collector:
|
||||
processes = self.daemon_instance.storage_collector.get_hardware_processes()
|
||||
storage = self._get_storage()
|
||||
if storage:
|
||||
processes = storage.get_hardware_processes()
|
||||
if processes:
|
||||
return self._success(processes)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user