diff --git a/setup.py b/setup.py index b3478e5..73ad2dd 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ def read(*paths): setuptools.setup( name='netutils-linux', - version='2.7.5', + version='2.7.6', author='Oleg Strizhechenko', author_email='oleg.strizhechenko@gmail.com', license='MIT', diff --git a/utils/netdev-pci-speed b/utils/netdev-pci-speed new file mode 100755 index 0000000..8446e00 --- /dev/null +++ b/utils/netdev-pci-speed @@ -0,0 +1,33 @@ +#!/bin/bash + +device=$1 +bus_addr="$(ethtool -i $device | grep bus | awk '{print $2}')" +dev_speed="$(ethtool eth1 | grep Speed | egrep -o [0-9]+)" +pci_type="$(dmidecode --type slot | grep -B6 0000:af:00.0 | egrep -m1 -o 'PCI Express [0-9] x[0-9]+')" +read _ _ version x <<< "$pci_type" +if [ "$version" = '1' ]; then + [ "$x" = 'x1' ] && slot_speed=250 + [ "$x" = 'x2' ] && slot_speed=500 + [ "$x" = 'x4' ] && slot_speed=1000 + [ "$x" = 'x8' ] && slot_speed=2000 + [ "$x" = 'x16' ] && slot_speed=4000 +elif [ "$version" = '2' ]; then + [ "$x" = 'x1' ] && slot_speed=500 + [ "$x" = 'x2' ] && slot_speed=1000 + [ "$x" = 'x4' ] && slot_speed=2000 + [ "$x" = 'x8' ] && slot_speed=4000 + [ "$x" = 'x16' ] && slot_speed=8000 +elif [ "$version" = '3' ]; then + [ "$x" = 'x1' ] && slot_speed=984 + [ "$x" = 'x2' ] && slot_speed=1970 + [ "$x" = 'x4' ] && slot_speed=3940 + [ "$x" = 'x8' ] && slot_speed=7880 + [ "$x" = 'x16' ] && slot_speed=15800 +elif [ "$version" = '4' ]; then + [ "$x" = 'x1' ] && slot_speed=1969 + [ "$x" = 'x2' ] && slot_speed=3940 + [ "$x" = 'x4' ] && slot_speed=7880 + [ "$x" = 'x8' ] && slot_speed=15750 + [ "$x" = 'x16' ] && slot_speed=31500 +fi +echo $device $dev_speed/$((slot_speed*8))