Fix network interface display for VLANs and physical NICs
All checks were successful
Build and Release / build-and-release (push) Successful in 1m11s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m11s
Agent changes: - Filter out ifb* interfaces from network display - Parse @parent notation for VLAN interfaces (e.g., lan@enp0s31f6) - Show physical interfaces even without IP addresses - Only filter virtual interfaces that have no IPs - Extract parent interface relationships for proper nesting Dashboard changes: - Nest VLAN/child interfaces under their physical parent - Show physical NICs with status icons even when down - Display child interfaces grouped under parent interface - Keep standalone virtual interfaces at root level Updated to version 0.1.169
This commit is contained in:
@@ -62,11 +62,19 @@ impl NetworkCollector {
|
||||
for iface in ifaces {
|
||||
let name = iface["ifname"].as_str().unwrap_or("").to_string();
|
||||
|
||||
// Skip loopback and empty names
|
||||
if name.is_empty() || name == "lo" {
|
||||
// Skip loopback, empty names, and ifb* interfaces
|
||||
if name.is_empty() || name == "lo" || name.starts_with("ifb") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parse parent interface from @parent notation (e.g., lan@enp0s31f6)
|
||||
let (interface_name, parent_interface) = if let Some(at_pos) = name.find('@') {
|
||||
let (child, parent) = name.split_at(at_pos);
|
||||
(child.to_string(), Some(parent[1..].to_string()))
|
||||
} else {
|
||||
(name.clone(), None)
|
||||
};
|
||||
|
||||
let mut ipv4_addresses = Vec::new();
|
||||
let mut ipv6_addresses = Vec::new();
|
||||
|
||||
@@ -90,14 +98,15 @@ impl NetworkCollector {
|
||||
}
|
||||
}
|
||||
|
||||
// Only add interfaces that have at least one IP address
|
||||
// This filters out ifb*, dummy interfaces, etc. that have no IPs
|
||||
if ipv4_addresses.is_empty() && ipv6_addresses.is_empty() {
|
||||
// Determine if physical and get status
|
||||
let is_physical = Self::is_physical_interface(&interface_name);
|
||||
|
||||
// Only filter out virtual interfaces without IPs
|
||||
// Physical interfaces should always be shown even if down/no IPs
|
||||
if !is_physical && ipv4_addresses.is_empty() && ipv6_addresses.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine if physical and get status
|
||||
let is_physical = Self::is_physical_interface(&name);
|
||||
let link_status = if is_physical {
|
||||
Self::get_link_status(&name)
|
||||
} else {
|
||||
@@ -105,12 +114,12 @@ impl NetworkCollector {
|
||||
};
|
||||
|
||||
interfaces.push(NetworkInterfaceData {
|
||||
name,
|
||||
name: interface_name,
|
||||
ipv4_addresses,
|
||||
ipv6_addresses,
|
||||
is_physical,
|
||||
link_status,
|
||||
parent_interface: None,
|
||||
parent_interface,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user