-
Notifications
You must be signed in to change notification settings - Fork 74
/
nic-model-list
executable file
·50 lines (42 loc) · 1006 Bytes
/
nic-model-list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -eu
# echo "$0 $@ [$$] START" >&2
declare DEVICE_REGEX="(eth|em|en|bond|p[0-9]*p)[0-9\.]+"
if [ "{1:-}" == '--help' ]; then
echo "Info: $0 показывает модели сетевых карт в системе"
echo "Usage: $0 без параметров"
echo "Example: $0"
exit 0
fi
rx_buf() {
ethtool -g "$1" 2>/dev/null | tac | grep "RX:" | egrep -o "[0-9]+" | tr '\n' '/'| sed 's|/$||g'
return 0
}
show_device() {
local eth="$1"
local id="$2"
is_vlan=0
if ethtool -i "$eth" | grep -q '802.1Q VLAN Support'; then
is_vlan=1
fi
if [ "$is_vlan" = 0 ]; then
echo "$eth: $(grep -w $id /tmp/lspci.tmp) rx: $(rx_buf "$eth")"
else
echo "$eth: VLAN interface"
fi
return 0
}
main() {
local eth
local id
for eth in $(egrep -o "$DEVICE_REGEX" /proc/net/dev | sort -u); do
for id in $(ethtool -i "$eth" | grep bus-info | sed 's/.*0000:https://'); do
show_device "$eth" "$id"
done
done
return 0
}
lspci > /tmp/lspci.tmp
main
# echo "$0 $@ [$$] SUCCESS"
exit 0