This commit is contained in:
2026-02-02 15:35:30 -05:00
parent 806d883476
commit f5df832941

View File

@@ -159,10 +159,13 @@ get_network_info() {
get_detailed_network() {
echo -e "\n${GREEN}=== Network Interface Statistics ===${NC}"
# Show only physical interfaces and bridges, skip virtual/firewall interfaces
for iface in $(ls /sys/class/net | grep -v lo | grep -v -E "^veth|^fwbr|^fwln|^fwpr|^tap"); do
local iface
while IFS= read -r iface; do
[[ -z "$iface" ]] && continue
ip -s link show "$iface" 2>/dev/null
done
done < <(get_physical_interfaces)
echo -e "\n${GREEN}=== Network Statistics ===${NC}"
if command -v ss >/dev/null 2>&1; then
ss -s
@@ -232,42 +235,68 @@ get_memory_details() {
get_nic_details() {
echo -e "\n${GREEN}=== Network Interface Details ===${NC}"
# Show only physical interfaces and bridges, skip virtual/firewall interfaces
for iface in $(ls /sys/class/net | grep -v lo | grep -v -E "^veth|^fwbr|^fwln|^fwpr|^tap"); do
local iface
while IFS= read -r iface; do
[[ -z "$iface" ]] && continue
echo -e "\n${GREEN}Interface: $iface${NC}"
# Get driver info
if [ -L "/sys/class/net/$iface/device/driver" ]; then
driver=$(basename $(readlink /sys/class/net/$iface/device/driver))
if [[ -L "/sys/class/net/$iface/device/driver" ]]; then
local driver
driver=$(basename "$(readlink "/sys/class/net/$iface/device/driver")")
echo -e " Driver: $driver"
fi
# Get MAC address
if [ -f "/sys/class/net/$iface/address" ]; then
echo -e " MAC: $(cat /sys/class/net/$iface/address)"
if [[ -f "/sys/class/net/$iface/address" ]]; then
echo -e " MAC: $(cat "/sys/class/net/$iface/address")"
fi
# Get link state
if [ -f "/sys/class/net/$iface/operstate" ]; then
echo -e " State: $(cat /sys/class/net/$iface/operstate)"
if [[ -f "/sys/class/net/$iface/operstate" ]]; then
echo -e " State: $(cat "/sys/class/net/$iface/operstate")"
fi
# Use ethtool if available
if command -v ethtool >/dev/null 2>&1; then
# Get speed and duplex
link_info=$(ethtool $iface 2>/dev/null | grep -E "Speed:|Duplex:|Link detected:")
if [ -n "$link_info" ]; then
echo "$link_info" | while read line; do
local link_info
link_info=$(ethtool "$iface" 2>/dev/null | grep -E "Speed:|Duplex:|Link detected:")
if [[ -n "$link_info" ]]; then
echo "$link_info" | while IFS= read -r line; do
echo -e " $line"
done
fi
# Get firmware version
fw_ver=$(ethtool -i $iface 2>/dev/null | grep "firmware-version" | awk '{print $2}')
if [ -n "$fw_ver" ] && [ "$fw_ver" != "" ]; then
local fw_ver
fw_ver=$(ethtool -i "$iface" 2>/dev/null | grep "firmware-version" | awk '{print $2}')
if [[ -n "$fw_ver" ]]; then
echo -e " Firmware: $fw_ver"
fi
fi
done < <(get_physical_interfaces)
}
get_physical_interfaces() {
local iface
for iface in /sys/class/net/*; do
# Skip if glob didn't match anything
[[ -e "$iface" ]] || continue
# Get just the interface name
iface=$(basename "$iface")
# Skip loopback
[[ "$iface" == "lo" ]] && continue
# Skip virtual/firewall interfaces
[[ "$iface" =~ ^(veth|fwbr|fwln|fwpr|tap) ]] && continue
# This is a physical interface
echo "$iface"
done
}