diff --git a/setup.py b/setup.py index a17d9a9..18f1066 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ def read(*paths): setuptools.setup( name='netutils-linux', - version='2.7.10', + version='2.7.11', author='Oleg Strizhechenko', author_email='oleg.strizhechenko@gmail.com', license='MIT', diff --git a/utils/nic-model-list b/utils/nic-model-list new file mode 100755 index 0000000..bf6c3c1 --- /dev/null +++ b/utils/nic-model-list @@ -0,0 +1,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://'); do + show_device "$eth" "$id" + done + done + return 0 +} + +lspci > /tmp/lspci.tmp +main + +# echo "$0 $@ [$$] SUCCESS" +exit 0