Skip to content

Commit

Permalink
Added(utils): netdev-pci-speed shows used/max throughput of NIC's PCI…
Browse files Browse the repository at this point in the history
… slot

Output in megabits only. Example:

$ netdev-pci-speed eth1
eth1 1000/126400
  • Loading branch information
strizhechenko committed Oct 17, 2018
1 parent d76d712 commit 9de1809
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
license='MIT',
Expand Down
33 changes: 33 additions & 0 deletions utils/netdev-pci-speed
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 9de1809

Please sign in to comment.