diff --git a/AppImage/components/network-metrics.tsx b/AppImage/components/network-metrics.tsx index 6489f1f9..c00cd3f8 100644 --- a/AppImage/components/network-metrics.tsx +++ b/AppImage/components/network-metrics.tsx @@ -21,6 +21,8 @@ interface NetworkData { packet_loss_out?: number dropin?: number dropout?: number + errin?: number + errout?: number } active_count?: number total_count?: number @@ -172,6 +174,23 @@ export function NetworkMetrics() { const trafficOutGB = (networkData.traffic.bytes_sent / 1024 ** 3).toFixed(2) const packetsRecvK = networkData.traffic.packets_recv ? (networkData.traffic.packets_recv / 1000).toFixed(0) : "0" + const totalErrors = (networkData.traffic.errin || 0) + (networkData.traffic.errout || 0) + const packetLossIn = networkData.traffic.packet_loss_in || 0 + const packetLossOut = networkData.traffic.packet_loss_out || 0 + const avgPacketLoss = ((packetLossIn + packetLossOut) / 2).toFixed(2) + + // Determine health status + let healthStatus = "Healthy" + let healthColor = "bg-green-500/10 text-green-500 border-green-500/20" + + if (Number.parseFloat(avgPacketLoss) > 5 || totalErrors > 1000) { + healthStatus = "Critical" + healthColor = "bg-red-500/10 text-red-500 border-red-500/20" + } else if (Number.parseFloat(avgPacketLoss) >= 1 || totalErrors >= 100) { + healthStatus = "Warning" + healthColor = "bg-yellow-500/10 text-yellow-500 border-yellow-500/20" + } + return (
{/* Network Overview Cards */} @@ -182,10 +201,15 @@ export function NetworkMetrics() { -
{trafficInGB} GB
-
- ↓ {trafficInGB} GB - ↑ {trafficOutGB} GB +
+
+ Received: + ↓ {trafficInGB} GB +
+
+ Sent: + ↑ {trafficOutGB} GB +

Total data transferred

@@ -232,17 +256,31 @@ export function NetworkMetrics() { - Packets + Network Health -
{packetsRecvK}K
-
- - Received +
+ + {healthStatus}
-

No packet loss

+
+
+ Packet Loss: + 1 ? "text-red-500" : "text-green-500"}`} + > + {avgPacketLoss}% + +
+
+ Errors: + 100 ? "text-red-500" : "text-green-500"}`}> + {totalErrors} + +
+