Damjan Marion | f0ccbb0 | 2016-10-06 16:53:32 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | echo "PCI Address MAC address Device Name Driver State Speed Port Type" |
| 4 | echo "============ ================= ============== ========== ======== ========== ====================" |
| 5 | |
| 6 | for f in /sys/class/net/*; do |
| 7 | dev=$(basename ${f}) |
| 8 | if [ -e $f/device ] ; then |
| 9 | dev=$(basename ${f}) |
| 10 | pci_addr=$(basename $(readlink $f/device)) |
| 11 | mac=$(cat $f/address) |
| 12 | driver=$(basename $(readlink $f/device/driver)) |
| 13 | oper=$(cat $f/operstate) |
| 14 | speed=$(sudo ethtool $dev | grep Speed | cut -d" " -f2) |
| 15 | port=$(ethtool $dev 2> /dev/null | sed -ne 's/.*Port: \(.*\)/\1/p') |
| 16 | printf "%-12s %-14s %-14s %-10s %-8s %-10s %-20s\n" $pci_addr $mac $dev $driver $oper $speed "$port" |
| 17 | # ethtool $dev | grep Port: |
| 18 | fi |
| 19 | done |
| 20 | |