diff --git a/AppImage/components/network-metrics.tsx b/AppImage/components/network-metrics.tsx index 145e5ab..de956a5 100644 --- a/AppImage/components/network-metrics.tsx +++ b/AppImage/components/network-metrics.tsx @@ -146,7 +146,7 @@ export function NetworkMetrics() { error, isLoading, } = useSWR("/api/network", fetcher, { - refreshInterval: 30000, // Refresh every 30 seconds + refreshInterval: 60000, // Refresh every 60 seconds revalidateOnFocus: false, revalidateOnReconnect: true, }) @@ -214,9 +214,19 @@ export function NetworkMetrics() { healthColor = "bg-yellow-500/10 text-yellow-500 border-yellow-500/20" } - const totalBandwidth = [...(networkData.physical_interfaces || []), ...(networkData.bridge_interfaces || [])] - .filter((iface) => iface.status === "up") - .reduce((sum, iface) => sum + (iface.speed || 0), 0) + const allInterfaces = [ + ...(networkData.physical_interfaces || []), + ...(networkData.bridge_interfaces || []), + ...(networkData.vm_lxc_interfaces || []), + ] + + const topInterface = allInterfaces.reduce((top, iface) => { + const ifaceTraffic = (iface.bytes_recv || 0) + (iface.bytes_sent || 0) + const topTraffic = (top.bytes_recv || 0) + (top.bytes_sent || 0) + return ifaceTraffic > topTraffic ? iface : top + }, allInterfaces[0] || { name: "N/A", type: "unknown", bytes_recv: 0, bytes_sent: 0 }) + + const topInterfaceTraffic = (topInterface.bytes_recv || 0) + (topInterface.bytes_sent || 0) const getTimeframeLabel = () => { switch (timeframe) { @@ -283,15 +293,17 @@ export function NetworkMetrics() { - Total Bandwidth - + Top Interface + -
{formatSpeed(totalBandwidth)}
-

- Combined speed of {(networkData.physical_active_count ?? 0) + (networkData.bridge_active_count ?? 0)}{" "} - active interfaces -

+
{topInterface.name}
+
+ + {getInterfaceTypeBadge(topInterface.type).label} + +
+

Total traffic: {formatBytes(topInterfaceTraffic)}

@@ -636,7 +648,7 @@ export function NetworkMetrics() { {/* Interface Details Modal */} setSelectedInterface(null)}> - + diff --git a/AppImage/components/network-traffic-chart.tsx b/AppImage/components/network-traffic-chart.tsx index 9fcce62..c39934c 100644 --- a/AppImage/components/network-traffic-chart.tsx +++ b/AppImage/components/network-traffic-chart.tsx @@ -208,7 +208,7 @@ export function NetworkTrafficChart({ timeframe, interfaceName, onTotalsCalculat return ( - +