Vasily.onl d5db9402e8 Add system health monitoring features with modular callbacks
- Introduced a new `system_health_constants.py` file to define thresholds and constants for system health metrics.
- Refactored existing system health callbacks into modular components, enhancing maintainability and clarity.
- Implemented dynamic loading of time range options in `charts.py`, improving flexibility in time range selection.
- Added detailed documentation for new callback functions, ensuring clarity on their purpose and usage.
- Enhanced error handling and logging practices across the new modules to ensure robust monitoring and debugging capabilities.

These changes significantly improve the architecture and maintainability of the system health monitoring features, aligning with project standards for modularity and performance.
2025-06-11 19:33:08 +08:00

26 lines
1.0 KiB
Python

from utils.logger import get_logger
from database.connection import DatabaseManager
from database.redis_manager import get_sync_redis_manager
import psutil
from datetime import datetime, timedelta
import dash_bootstrap_components as dbc
from dash import html
logger = get_logger("default_logger")
def _check_data_collection_service_running() -> bool:
"""Check if data collection service is running."""
try:
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
try:
if proc.info['cmdline']:
cmdline = ' '.join(proc.info['cmdline'])
if 'start_data_collection.py' in cmdline or 'collection_service' in cmdline:
return True
except (psutil.NoSuchProcess, psutil.AccessDenied) as e:
logger.warning(f"Access or process error checking service: {e}")
continue
return False
except Exception as e:
logger.error(f"Error checking data collection service running status: {e}")
return False