mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-10-11 12:26:18 +00:00
Update AppImage
This commit is contained in:
@@ -8,8 +8,7 @@ import { Wifi, Globe, Shield, Activity, Network, Router, AlertCircle, Zap } from
|
|||||||
import useSWR from "swr"
|
import useSWR from "swr"
|
||||||
|
|
||||||
interface NetworkData {
|
interface NetworkData {
|
||||||
physical_interfaces?: NetworkInterface[]
|
interfaces: NetworkInterface[]
|
||||||
bridge_interfaces?: NetworkInterface[]
|
|
||||||
vm_lxc_interfaces?: NetworkInterface[]
|
vm_lxc_interfaces?: NetworkInterface[]
|
||||||
traffic: {
|
traffic: {
|
||||||
bytes_sent: number
|
bytes_sent: number
|
||||||
@@ -18,11 +17,11 @@ interface NetworkData {
|
|||||||
packets_recv?: number
|
packets_recv?: number
|
||||||
packet_loss_in?: number
|
packet_loss_in?: number
|
||||||
packet_loss_out?: number
|
packet_loss_out?: number
|
||||||
|
dropin?: number
|
||||||
|
dropout?: number
|
||||||
}
|
}
|
||||||
physical_active_count?: number
|
active_count?: number
|
||||||
physical_total_count?: number
|
total_count?: number
|
||||||
bridge_active_count?: number
|
|
||||||
bridge_total_count?: number
|
|
||||||
vm_lxc_active_count?: number
|
vm_lxc_active_count?: number
|
||||||
vm_lxc_total_count?: number
|
vm_lxc_total_count?: number
|
||||||
}
|
}
|
||||||
@@ -69,6 +68,10 @@ const getInterfaceTypeBadge = (type: string) => {
|
|||||||
return { color: "bg-purple-500/10 text-purple-500 border-purple-500/20", label: "Bond" }
|
return { color: "bg-purple-500/10 text-purple-500 border-purple-500/20", label: "Bond" }
|
||||||
case "vlan":
|
case "vlan":
|
||||||
return { color: "bg-cyan-500/10 text-cyan-500 border-cyan-500/20", label: "VLAN" }
|
return { color: "bg-cyan-500/10 text-cyan-500 border-cyan-500/20", label: "VLAN" }
|
||||||
|
case "vm_lxc":
|
||||||
|
return { color: "bg-orange-500/10 text-orange-500 border-orange-500/20", label: "Virtual" }
|
||||||
|
case "virtual":
|
||||||
|
return { color: "bg-orange-500/10 text-orange-500 border-orange-500/20", label: "Virtual" }
|
||||||
default:
|
default:
|
||||||
return { color: "bg-gray-500/10 text-gray-500 border-gray-500/20", label: "Unknown" }
|
return { color: "bg-gray-500/10 text-gray-500 border-gray-500/20", label: "Unknown" }
|
||||||
}
|
}
|
||||||
@@ -98,10 +101,7 @@ const formatSpeed = (speed: number): string => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fetcher = async (url: string): Promise<NetworkData> => {
|
const fetcher = async (url: string): Promise<NetworkData> => {
|
||||||
const baseUrl = typeof window !== "undefined" ? `${window.location.protocol}//${window.location.hostname}:8008` : ""
|
const response = await fetch(url, {
|
||||||
const fullUrl = `${baseUrl}${url}`
|
|
||||||
|
|
||||||
const response = await fetch(fullUrl, {
|
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -122,7 +122,7 @@ export function NetworkMetrics() {
|
|||||||
error,
|
error,
|
||||||
isLoading,
|
isLoading,
|
||||||
} = useSWR<NetworkData>("/api/network", fetcher, {
|
} = useSWR<NetworkData>("/api/network", fetcher, {
|
||||||
refreshInterval: 30000,
|
refreshInterval: 30000, // Refresh every 30 seconds
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
revalidateOnReconnect: true,
|
revalidateOnReconnect: true,
|
||||||
})
|
})
|
||||||
@@ -164,10 +164,6 @@ export function NetworkMetrics() {
|
|||||||
const trafficOutGB = (networkData.traffic.bytes_sent / 1024 ** 3).toFixed(2)
|
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 packetsRecvK = networkData.traffic.packets_recv ? (networkData.traffic.packets_recv / 1000).toFixed(0) : "0"
|
||||||
|
|
||||||
const physicalInterfaces = networkData.physical_interfaces || []
|
|
||||||
const bridgeInterfaces = networkData.bridge_interfaces || []
|
|
||||||
const vmLxcInterfaces = networkData.vm_lxc_interfaces || []
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
{/* Network Overview Cards */}
|
{/* Network Overview Cards */}
|
||||||
@@ -193,23 +189,13 @@ export function NetworkMetrics() {
|
|||||||
<Network className="h-4 w-4 text-muted-foreground" />
|
<Network className="h-4 w-4 text-muted-foreground" />
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="text-2xl font-bold text-foreground">
|
<div className="text-2xl font-bold text-foreground">{networkData.active_count ?? 0}</div>
|
||||||
{(networkData.physical_active_count ?? 0) + (networkData.bridge_active_count ?? 0)}
|
<div className="flex items-center mt-2">
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-1 mt-2">
|
|
||||||
<div className="flex items-center justify-between text-xs">
|
|
||||||
<span className="text-muted-foreground">Physical:</span>
|
|
||||||
<Badge variant="outline" className="bg-blue-500/10 text-blue-500 border-blue-500/20">
|
|
||||||
{networkData.physical_active_count ?? 0}/{networkData.physical_total_count ?? 0}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center justify-between text-xs">
|
|
||||||
<span className="text-muted-foreground">Bridges:</span>
|
|
||||||
<Badge variant="outline" className="bg-green-500/10 text-green-500 border-green-500/20">
|
<Badge variant="outline" className="bg-green-500/10 text-green-500 border-green-500/20">
|
||||||
{networkData.bridge_active_count ?? 0}/{networkData.bridge_total_count ?? 0}
|
Online
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<p className="text-xs text-muted-foreground mt-2">{networkData.total_count ?? 0} total interfaces</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -251,33 +237,30 @@ export function NetworkMetrics() {
|
|||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Physical Interfaces */}
|
{/* Network Interfaces */}
|
||||||
{physicalInterfaces.length > 0 && (
|
|
||||||
<Card className="bg-card border-border">
|
<Card className="bg-card border-border">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-foreground flex items-center">
|
<CardTitle className="text-foreground flex items-center">
|
||||||
<Router className="h-5 w-5 mr-2" />
|
<Router className="h-5 w-5 mr-2" />
|
||||||
Physical Interfaces
|
Network Interfaces
|
||||||
<Badge variant="outline" className="ml-3 bg-blue-500/10 text-blue-500 border-blue-500/20">
|
|
||||||
{networkData.physical_active_count ?? 0}/{networkData.physical_total_count ?? 0} Active
|
|
||||||
</Badge>
|
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{physicalInterfaces.map((iface, index) => {
|
{networkData.interfaces.map((interface_, index) => {
|
||||||
const typeBadge = getInterfaceTypeBadge(iface.type)
|
const typeBadge = getInterfaceTypeBadge(interface_.type)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer"
|
className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer"
|
||||||
onClick={() => setSelectedInterface(iface)}
|
onClick={() => setSelectedInterface(interface_)}
|
||||||
>
|
>
|
||||||
|
{/* First row: Icon, Name, Type Badge, Status */}
|
||||||
<div className="flex items-center gap-3 flex-wrap">
|
<div className="flex items-center gap-3 flex-wrap">
|
||||||
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
|
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
|
||||||
<div className="flex items-center gap-2 min-w-0">
|
<div className="flex items-center gap-2 min-w-0">
|
||||||
<div className="font-medium text-foreground">{iface.name}</div>
|
<div className="font-medium text-foreground">{interface_.name}</div>
|
||||||
<Badge variant="outline" className={typeBadge.color}>
|
<Badge variant="outline" className={typeBadge.color}>
|
||||||
{typeBadge.label}
|
{typeBadge.label}
|
||||||
</Badge>
|
</Badge>
|
||||||
@@ -285,20 +268,21 @@ export function NetworkMetrics() {
|
|||||||
<Badge
|
<Badge
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className={
|
className={
|
||||||
iface.status === "up"
|
interface_.status === "up"
|
||||||
? "bg-green-500/10 text-green-500 border-green-500/20 ml-auto"
|
? "bg-green-500/10 text-green-500 border-green-500/20 ml-auto"
|
||||||
: "bg-red-500/10 text-red-500 border-red-500/20 ml-auto"
|
: "bg-red-500/10 text-red-500 border-red-500/20 ml-auto"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{iface.status.toUpperCase()}
|
{interface_.status.toUpperCase()}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Second row: Details - Responsive layout */}
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
|
||||||
<div>
|
<div>
|
||||||
<div className="text-muted-foreground text-xs">IP Address</div>
|
<div className="text-muted-foreground text-xs">IP Address</div>
|
||||||
<div className="font-medium text-foreground font-mono text-sm truncate">
|
<div className="font-medium text-foreground font-mono text-sm truncate">
|
||||||
{iface.addresses.length > 0 ? iface.addresses[0].ip : "N/A"}
|
{interface_.addresses.length > 0 ? interface_.addresses[0].ip : "N/A"}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -306,24 +290,24 @@ export function NetworkMetrics() {
|
|||||||
<div className="text-muted-foreground text-xs">Speed</div>
|
<div className="text-muted-foreground text-xs">Speed</div>
|
||||||
<div className="font-medium text-foreground flex items-center gap-1">
|
<div className="font-medium text-foreground flex items-center gap-1">
|
||||||
<Zap className="h-3 w-3" />
|
<Zap className="h-3 w-3" />
|
||||||
{formatSpeed(iface.speed)}
|
{formatSpeed(interface_.speed)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-span-2 md:col-span-1">
|
<div className="col-span-2 md:col-span-1">
|
||||||
<div className="text-muted-foreground text-xs">Traffic</div>
|
<div className="text-muted-foreground text-xs">Traffic</div>
|
||||||
<div className="font-medium text-foreground text-xs">
|
<div className="font-medium text-foreground text-xs">
|
||||||
<span className="text-green-500">↓ {formatBytes(iface.bytes_recv)}</span>
|
<span className="text-green-500">↓ {formatBytes(interface_.bytes_recv)}</span>
|
||||||
{" / "}
|
{" / "}
|
||||||
<span className="text-blue-500">↑ {formatBytes(iface.bytes_sent)}</span>
|
<span className="text-blue-500">↑ {formatBytes(interface_.bytes_sent)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{iface.mac_address && (
|
{interface_.mac_address && (
|
||||||
<div className="col-span-2 md:col-span-1">
|
<div className="col-span-2 md:col-span-1">
|
||||||
<div className="text-muted-foreground text-xs">MAC</div>
|
<div className="text-muted-foreground text-xs">MAC</div>
|
||||||
<div className="font-medium text-foreground font-mono text-xs truncate">
|
<div className="font-medium text-foreground font-mono text-xs truncate">
|
||||||
{iface.mac_address}
|
{interface_.mac_address}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -334,167 +318,82 @@ export function NetworkMetrics() {
|
|||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Bridge Interfaces */}
|
{networkData.vm_lxc_interfaces && networkData.vm_lxc_interfaces.length > 0 && (
|
||||||
{bridgeInterfaces.length > 0 && (
|
|
||||||
<Card className="bg-card border-border">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="text-foreground flex items-center">
|
|
||||||
<Network className="h-5 w-5 mr-2" />
|
|
||||||
Bridge Interfaces
|
|
||||||
<Badge variant="outline" className="ml-3 bg-green-500/10 text-green-500 border-green-500/20">
|
|
||||||
{networkData.bridge_active_count ?? 0}/{networkData.bridge_total_count ?? 0} Active
|
|
||||||
</Badge>
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<div className="space-y-4">
|
|
||||||
{bridgeInterfaces.map((iface, index) => {
|
|
||||||
const typeBadge = getInterfaceTypeBadge(iface.type)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer"
|
|
||||||
onClick={() => setSelectedInterface(iface)}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-3 flex-wrap">
|
|
||||||
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
|
|
||||||
<div className="flex items-center gap-2 min-w-0">
|
|
||||||
<div className="font-medium text-foreground">{iface.name}</div>
|
|
||||||
<Badge variant="outline" className={typeBadge.color}>
|
|
||||||
{typeBadge.label}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
<Badge
|
|
||||||
variant="outline"
|
|
||||||
className={
|
|
||||||
iface.status === "up"
|
|
||||||
? "bg-green-500/10 text-green-500 border-green-500/20 ml-auto"
|
|
||||||
: "bg-red-500/10 text-red-500 border-red-500/20 ml-auto"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{iface.status.toUpperCase()}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
|
|
||||||
<div>
|
|
||||||
<div className="text-muted-foreground text-xs">IP Address</div>
|
|
||||||
<div className="font-medium text-foreground font-mono text-sm truncate">
|
|
||||||
{iface.addresses.length > 0 ? iface.addresses[0].ip : "N/A"}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div className="text-muted-foreground text-xs">Speed</div>
|
|
||||||
<div className="font-medium text-foreground flex items-center gap-1">
|
|
||||||
<Zap className="h-3 w-3" />
|
|
||||||
{formatSpeed(iface.speed)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-span-2 md:col-span-1">
|
|
||||||
<div className="text-muted-foreground text-xs">Traffic</div>
|
|
||||||
<div className="font-medium text-foreground text-xs">
|
|
||||||
<span className="text-green-500">↓ {formatBytes(iface.bytes_recv)}</span>
|
|
||||||
{" / "}
|
|
||||||
<span className="text-blue-500">↑ {formatBytes(iface.bytes_sent)}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{iface.mac_address && (
|
|
||||||
<div className="col-span-2 md:col-span-1">
|
|
||||||
<div className="text-muted-foreground text-xs">MAC</div>
|
|
||||||
<div className="font-medium text-foreground font-mono text-xs truncate">
|
|
||||||
{iface.mac_address}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* VM & LXC Network Interfaces */}
|
|
||||||
{vmLxcInterfaces.length > 0 && (
|
|
||||||
<Card className="bg-card border-border">
|
<Card className="bg-card border-border">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-foreground flex items-center">
|
<CardTitle className="text-foreground flex items-center">
|
||||||
<Network className="h-5 w-5 mr-2" />
|
<Network className="h-5 w-5 mr-2" />
|
||||||
VM & LXC Network Interfaces
|
VM & LXC Network Interfaces
|
||||||
<Badge variant="outline" className="ml-3 bg-orange-500/10 text-orange-500 border-orange-500/20">
|
<Badge variant="outline" className="ml-3 bg-orange-500/10 text-orange-500 border-orange-500/20">
|
||||||
{networkData.vm_lxc_active_count ?? 0}/{networkData.vm_lxc_total_count ?? 0} Active
|
{networkData.vm_lxc_active_count ?? 0} / {networkData.vm_lxc_total_count ?? 0} Active
|
||||||
</Badge>
|
</Badge>
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{vmLxcInterfaces.map((iface, index) => {
|
{networkData.vm_lxc_interfaces.map((interface_, index) => {
|
||||||
const vmTypeBadge = getVMTypeBadge(iface.vm_type)
|
const vmTypeBadge = getVMTypeBadge(interface_.vm_type)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer"
|
className="flex flex-col gap-3 p-4 rounded-lg border border-border bg-card/50 hover:bg-card/80 transition-colors cursor-pointer"
|
||||||
onClick={() => setSelectedInterface(iface)}
|
onClick={() => setSelectedInterface(interface_)}
|
||||||
>
|
>
|
||||||
|
{/* First row: Icon, Name, VM/LXC Badge, VM Name, Status */}
|
||||||
<div className="flex items-center gap-3 flex-wrap">
|
<div className="flex items-center gap-3 flex-wrap">
|
||||||
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
|
<Wifi className="h-5 w-5 text-muted-foreground flex-shrink-0" />
|
||||||
<div className="flex items-center gap-2 min-w-0 flex-1">
|
<div className="flex items-center gap-2 min-w-0 flex-1">
|
||||||
<div className="font-medium text-foreground">{iface.name}</div>
|
<div className="font-medium text-foreground">{interface_.name}</div>
|
||||||
<Badge variant="outline" className={vmTypeBadge.color}>
|
<Badge variant="outline" className={vmTypeBadge.color}>
|
||||||
{vmTypeBadge.label}
|
{vmTypeBadge.label}
|
||||||
</Badge>
|
</Badge>
|
||||||
{iface.vm_name && (
|
{interface_.vm_name && (
|
||||||
<div className="text-sm text-muted-foreground truncate">→ {iface.vm_name}</div>
|
<div className="text-sm text-muted-foreground truncate">→ {interface_.vm_name}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Badge
|
<Badge
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className={
|
className={
|
||||||
iface.status === "up"
|
interface_.status === "up"
|
||||||
? "bg-green-500/10 text-green-500 border-green-500/20"
|
? "bg-green-500/10 text-green-500 border-green-500/20"
|
||||||
: "bg-red-500/10 text-red-500 border-red-500/20"
|
: "bg-red-500/10 text-red-500 border-red-500/20"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{iface.status.toUpperCase()}
|
{interface_.status.toUpperCase()}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Second row: Details - Responsive layout */}
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
|
||||||
<div>
|
<div>
|
||||||
<div className="text-muted-foreground text-xs">VMID</div>
|
<div className="text-muted-foreground text-xs">VMID</div>
|
||||||
<div className="font-medium text-foreground">{iface.vmid ?? "N/A"}</div>
|
<div className="font-medium text-foreground">{interface_.vmid ?? "N/A"}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div className="text-muted-foreground text-xs">Speed</div>
|
<div className="text-muted-foreground text-xs">Speed</div>
|
||||||
<div className="font-medium text-foreground flex items-center gap-1">
|
<div className="font-medium text-foreground flex items-center gap-1">
|
||||||
<Zap className="h-3 w-3" />
|
<Zap className="h-3 w-3" />
|
||||||
{formatSpeed(iface.speed)}
|
{formatSpeed(interface_.speed)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-span-2 md:col-span-1">
|
<div className="col-span-2 md:col-span-1">
|
||||||
<div className="text-muted-foreground text-xs">Traffic</div>
|
<div className="text-muted-foreground text-xs">Traffic</div>
|
||||||
<div className="font-medium text-foreground text-xs">
|
<div className="font-medium text-foreground text-xs">
|
||||||
<span className="text-green-500">↓ {formatBytes(iface.bytes_recv)}</span>
|
<span className="text-green-500">↓ {formatBytes(interface_.bytes_recv)}</span>
|
||||||
{" / "}
|
{" / "}
|
||||||
<span className="text-blue-500">↑ {formatBytes(iface.bytes_sent)}</span>
|
<span className="text-blue-500">↑ {formatBytes(interface_.bytes_sent)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{iface.mac_address && (
|
{interface_.mac_address && (
|
||||||
<div className="col-span-2 md:col-span-1">
|
<div className="col-span-2 md:col-span-1">
|
||||||
<div className="text-muted-foreground text-xs">MAC</div>
|
<div className="text-muted-foreground text-xs">MAC</div>
|
||||||
<div className="font-medium text-foreground font-mono text-xs truncate">
|
<div className="font-medium text-foreground font-mono text-xs truncate">
|
||||||
{iface.mac_address}
|
{interface_.mac_address}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -507,7 +406,7 @@ export function NetworkMetrics() {
|
|||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Interface Details Dialog */}
|
{/* Interface Details Modal */}
|
||||||
<Dialog open={!!selectedInterface} onOpenChange={() => setSelectedInterface(null)}>
|
<Dialog open={!!selectedInterface} onOpenChange={() => setSelectedInterface(null)}>
|
||||||
<DialogContent className="max-w-2xl max-h-[80vh] overflow-y-auto">
|
<DialogContent className="max-w-2xl max-h-[80vh] overflow-y-auto">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
|
@@ -857,7 +857,7 @@ def get_proxmox_storage():
|
|||||||
print(f"[v0] pvesm status failed with return code {result.returncode}")
|
print(f"[v0] pvesm status failed with return code {result.returncode}")
|
||||||
print(f"[v0] stderr: {result.stderr}")
|
print(f"[v0] stderr: {result.stderr}")
|
||||||
return {
|
return {
|
||||||
'error': 'pvesh command not available or failed',
|
'error': 'pvesm command not available or failed',
|
||||||
'storage': []
|
'storage': []
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1001,12 +1001,11 @@ def get_bridge_info(bridge_name):
|
|||||||
return bridge_info
|
return bridge_info
|
||||||
|
|
||||||
def get_network_info():
|
def get_network_info():
|
||||||
"""Get network interface information - Enhanced with separation of physical and bridge interfaces"""
|
"""Get network interface information - Enhanced with VM/LXC interface separation"""
|
||||||
try:
|
try:
|
||||||
network_data = {
|
network_data = {
|
||||||
'physical_interfaces': [], # Separated physical interfaces
|
'interfaces': [],
|
||||||
'bridge_interfaces': [], # Separated bridge interfaces
|
'vm_lxc_interfaces': [], # Added separate list for VM/LXC interfaces
|
||||||
'vm_lxc_interfaces': [],
|
|
||||||
'traffic': {'bytes_sent': 0, 'bytes_recv': 0, 'packets_sent': 0, 'packets_recv': 0}
|
'traffic': {'bytes_sent': 0, 'bytes_recv': 0, 'packets_sent': 0, 'packets_recv': 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1022,10 +1021,8 @@ def get_network_info():
|
|||||||
print(f"[v0] Error getting per-NIC stats: {e}")
|
print(f"[v0] Error getting per-NIC stats: {e}")
|
||||||
net_io_per_nic = {}
|
net_io_per_nic = {}
|
||||||
|
|
||||||
physical_active_count = 0
|
active_count = 0
|
||||||
physical_total_count = 0
|
total_count = 0
|
||||||
bridge_active_count = 0
|
|
||||||
bridge_total_count = 0
|
|
||||||
vm_lxc_active_count = 0
|
vm_lxc_active_count = 0
|
||||||
vm_lxc_total_count = 0
|
vm_lxc_total_count = 0
|
||||||
|
|
||||||
@@ -1044,14 +1041,10 @@ def get_network_info():
|
|||||||
vm_lxc_total_count += 1
|
vm_lxc_total_count += 1
|
||||||
if stats.isup:
|
if stats.isup:
|
||||||
vm_lxc_active_count += 1
|
vm_lxc_active_count += 1
|
||||||
elif interface_type == 'physical':
|
else:
|
||||||
physical_total_count += 1
|
total_count += 1
|
||||||
if stats.isup:
|
if stats.isup:
|
||||||
physical_active_count += 1
|
active_count += 1
|
||||||
elif interface_type == 'bridge':
|
|
||||||
bridge_total_count += 1
|
|
||||||
if stats.isup:
|
|
||||||
bridge_active_count += 1
|
|
||||||
|
|
||||||
interface_info = {
|
interface_info = {
|
||||||
'name': interface_name,
|
'name': interface_name,
|
||||||
@@ -1122,20 +1115,15 @@ def get_network_info():
|
|||||||
|
|
||||||
if interface_type == 'vm_lxc':
|
if interface_type == 'vm_lxc':
|
||||||
network_data['vm_lxc_interfaces'].append(interface_info)
|
network_data['vm_lxc_interfaces'].append(interface_info)
|
||||||
elif interface_type == 'physical':
|
else:
|
||||||
network_data['physical_interfaces'].append(interface_info)
|
network_data['interfaces'].append(interface_info)
|
||||||
elif interface_type == 'bridge':
|
|
||||||
network_data['bridge_interfaces'].append(interface_info)
|
|
||||||
|
|
||||||
network_data['physical_active_count'] = physical_active_count
|
network_data['active_count'] = active_count
|
||||||
network_data['physical_total_count'] = physical_total_count
|
network_data['total_count'] = total_count
|
||||||
network_data['bridge_active_count'] = bridge_active_count
|
|
||||||
network_data['bridge_total_count'] = bridge_total_count
|
|
||||||
network_data['vm_lxc_active_count'] = vm_lxc_active_count
|
network_data['vm_lxc_active_count'] = vm_lxc_active_count
|
||||||
network_data['vm_lxc_total_count'] = vm_lxc_total_count
|
network_data['vm_lxc_total_count'] = vm_lxc_total_count
|
||||||
|
|
||||||
print(f"[v0] Physical interfaces: {physical_active_count} active out of {physical_total_count} total")
|
print(f"[v0] Physical interfaces: {active_count} active out of {total_count} total")
|
||||||
print(f"[v0] Bridge interfaces: {bridge_active_count} active out of {bridge_total_count} total")
|
|
||||||
print(f"[v0] VM/LXC interfaces: {vm_lxc_active_count} active out of {vm_lxc_total_count} total")
|
print(f"[v0] VM/LXC interfaces: {vm_lxc_active_count} active out of {vm_lxc_total_count} total")
|
||||||
|
|
||||||
# Get network I/O statistics (global)
|
# Get network I/O statistics (global)
|
||||||
@@ -1171,14 +1159,11 @@ def get_network_info():
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return {
|
return {
|
||||||
'error': f'Unable to access network information: {str(e)}',
|
'error': f'Unable to access network information: {str(e)}',
|
||||||
'physical_interfaces': [],
|
'interfaces': [],
|
||||||
'bridge_interfaces': [],
|
|
||||||
'vm_lxc_interfaces': [],
|
'vm_lxc_interfaces': [],
|
||||||
'traffic': {'bytes_sent': 0, 'bytes_recv': 0, 'packets_sent': 0, 'packets_recv': 0},
|
'traffic': {'bytes_sent': 0, 'bytes_recv': 0, 'packets_sent': 0, 'packets_recv': 0},
|
||||||
'physical_active_count': 0,
|
'active_count': 0,
|
||||||
'physical_total_count': 0,
|
'total_count': 0,
|
||||||
'bridge_active_count': 0,
|
|
||||||
'bridge_total_count': 0,
|
|
||||||
'vm_lxc_active_count': 0,
|
'vm_lxc_active_count': 0,
|
||||||
'vm_lxc_total_count': 0
|
'vm_lxc_total_count': 0
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user