import React, { useState, useEffect } from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts'; import { Activity, Cpu, HardDrive, Wifi } from 'lucide-react'; /** * System Monitoring Dashboard * * Real-time infrastructure monitoring with: * - Gauge widgets for CPU, memory, disk * - Live request rate chart (SSE updates) * - Alert indicators for threshold breaches * - Color-coded health status */ interface GaugeProps { title: string; value: number; max: number; unit: string; icon: React.ReactNode; } function Gauge({ title, value, max, unit, icon }: GaugeProps) { const percentage = (value / max) * 100; const color = percentage >= 90 ? '#ef4444' : percentage >= 70 ? '#f59e0b' : '#10b981'; return (
{icon}
{title}
{/* Gauge background */} {/* Background arc */} {/* Value arc */}
{value.toFixed(1)} {unit}
of {max}{unit}
); } export function MonitoringDashboard() { const [metricsData, setMetricsData] = useState([ { time: '10:00', requests: 1200 }, { time: '10:05', requests: 1350 }, { time: '10:10', requests: 1180 }, { time: '10:15', requests: 1420 }, { time: '10:20', requests: 1560 }, { time: '10:25', requests: 1380 }, ]); // Simulate real-time updates (replace with actual SSE) useEffect(() => { const interval = setInterval(() => { setMetricsData((prev) => { const newData = [...prev.slice(1)]; const lastTime = prev[prev.length - 1].time; const [hours, minutes] = lastTime.split(':').map(Number); const newMinutes = (minutes + 5) % 60; const newTime = `${hours}:${newMinutes.toString().padStart(2, '0')}`; newData.push({ time: newTime, requests: Math.floor(1000 + Math.random() * 600), }); return newData; }); }, 5000); return () => clearInterval(interval); }, []); return (

System Monitoring

All Systems Operational
{/* Gauge Widgets */}
} /> } /> } /> } />
{/* Request Rate Chart */}

Request Rate (Real-time)

LIVE
); } export default MonitoringDashboard;