blob: ed590e533acb82e4344fed0ca86b564027862044 [file] [log] [blame]
Damjan Marionf0ccbb02016-10-06 16:53:32 +02001#!/bin/bash
2
3echo "PCI Address MAC address Device Name Driver State Speed Port Type"
4echo "============ ================= ============== ========== ======== ========== ===================="
5
6for 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
19done
20