| π Navigation: π Home | π Docs | π Quickstart | π Dashboard | π OSINT |
The integrated health monitoring system provides comprehensive monitoring and diagnostics for CrawlLama.
The Health Dashboard offers two modes in one application:
Interactive Menu:
# Windows
health-dashboard.bat
# Linux/Mac
./health-dashboard.sh
# Direct with Python
python health-dashboard.py
Direct Start Modes:
# Live System Monitor
python health-dashboard.py --monitor
# Test Dashboard
python health-dashboard.py --tests
Real-time monitoring with Rich Terminal UI:
Tkinter-based GUI for test management:
from pathlib import Path
from core.health import SystemMonitor
# Initialize
monitor = SystemMonitor(update_interval=1.0)
monitor.start()
# Get metrics
metrics = monitor.get_latest_metrics()
print(f"CPU: {metrics.cpu_percent}%")
print(f"Memory: {metrics.memory_used_gb}/{metrics.memory_total_gb} GB")
print(f"Disk: {metrics.disk_percent}%")
# Stop
monitor.stop()
from pathlib import Path
from core.health import ComponentHealthChecker, HealthStatus
# Initialize
checker = ComponentHealthChecker(Path.cwd())
# Check all components
health = checker.check_all()
# Display results
for name, status in health.items():
print(f"{name}: {status.status.value} - {status.message}")
print(f" Response Time: {status.response_time_ms:.2f}ms")
from core.health import PerformanceTracker, PerformanceTimer
# Initialize
tracker = PerformanceTracker()
# Track operation
with PerformanceTimer(tracker, "llm_query") as timer:
# Your operation here
result = expensive_operation()
# Get statistics
stats = tracker.get_stats("llm_query")
print(f"Average: {stats.avg_duration_ms:.2f}ms")
print(f"P95: {stats.p95_duration_ms:.2f}ms")
print(f"Success Rate: {stats.success_rate:.1f}%")
from core.health import AlertSystem, AlertLevel
# Initialize
alerts = AlertSystem()
# Register alert callback
def on_alert(alert):
print(f"[{alert.level.value}] {alert.component}: {alert.message}")
alerts.register_callback(on_alert)
# Check system data
alerts.check_alerts({
'system_metrics': monitor.get_latest_metrics(),
'component_health': checker.check_all(),
'performance_stats': tracker.get_all_stats()
})
# Get active alerts
active = alerts.get_alerts(unacknowledged_only=True)
for alert in active:
print(f"{alert.level.value}: {alert.message}")
from pathlib import Path
from core.health import RichHealthDashboard
# Start dashboard
dashboard = RichHealthDashboard(
project_root=Path.cwd(),
update_interval=2.0 # Seconds
)
dashboard.start() # Blocks until Ctrl+C
from core.llm_client import LLMClient
from core.health import PerformanceTracker
tracker = PerformanceTracker()
client = LLMClient("config.json")
# Wrapper function
def tracked_query(prompt: str):
with PerformanceTimer(tracker, "llm_query") as timer:
try:
response = client.generate(prompt)
return response
except Exception as e:
timer.mark_failure()
raise
# Use
response = tracked_query("What is AI?")
# Display statistics
stats = tracker.get_stats("llm_query")
print(f"Average response time: {stats.avg_duration_ms:.2f}ms")
from tools.web_search import web_search
from core.health import PerformanceTracker
tracker = PerformanceTracker()
def monitored_search(query: str):
with PerformanceTimer(tracker, "web_search"):
return web_search(query)
# Use
results = monitored_search("Python tutorials")
| Rule | Threshold | Level | Description |
|---|---|---|---|
| CPU Warning | 85% | WARNING | High CPU usage |
| CPU Error | 95% | ERROR | Critical CPU usage |
| Memory Warning | 85% | WARNING | High RAM usage |
| Memory Error | 95% | ERROR | Critical RAM usage |
| Disk Warning | 5 GB free | WARNING | Low storage space |
| Disk Critical | 1 GB free | CRITICAL | Very low storage space |
| Component Health | Unhealthy | ERROR | Component failure |
| Performance | P95 > 5s | WARNING | Slow performance |
from core.health import AlertRule, AlertLevel
class CustomAlertRule(AlertRule):
def __init__(self):
super().__init__(
name="Custom Rule",
level=AlertLevel.WARNING,
cooldown_minutes=10
)
def check(self, data: dict) -> str | None:
# Your custom logic
if some_condition:
return "Custom alert message"
return None
# Add rule
alerts.add_rule(CustomAlertRule())
Problem: ModuleNotFoundError: No module named 'rich'
Solution:
pip install rich psutil
Problem: Metrics not displayed
Solution: Ensure psutil is installed:
pip install psutil
Problem: All components show βUnhealthyβ
Solution:
config.jsonmkdir -p data/cache data/embeddings logs
Problem: No performance statistics
Solution: Integrate PerformanceTimer in your code (see examples above)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π¦ CrawlLama Health Dashboard | 2025-10-24 14:30:00 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β π System Metrics β π Performance β
β β β
β CPU 45.2% ββββββ β llm_query 1250ms β β
β Memory 62.1% βββββββ β web_search 850ms β β
β Disk 38.5% ββββββ β cache_read 25ms β β
β Network β1.2/β0.3 MB/s β β
βββββββββββββββββββββββββββ€ β
β π Component Health β β
β β β
β LLM Client β 45ms β β
β Cache System β 12ms β β
β RAG System β 89ms β β
β Search Tools β 23ms β β
βββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π¨ Alerts (2) β
β β
β π‘ High CPU usage: 87.5% (threshold: 85.0%) β
β π Slow operations: llm_query (P95: 5200ms) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Alerts: π΄ 0 π 1 π‘ 1 | Press Ctrl+C to exit β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
PerformanceTimer for critical operations