Introducing.. lseth/lsnet
Hi everyone,
I am not sure about you but systems with many interfaces and ips hurt my eyes.
Thus, a few months ago, I started writing a small tool to help display relevant information in a more compact way.
I named this tool 'lseth' and its python rewrite will become 'lsnet'. It can display Linux bonds, the active interface and the current MAC of the bond.
Here's what it does:
On a RHEL7.1 system with OSP7, instead of this:
- # ip a s
- 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
- inet 127.0.0.1/8 scope host lo
- valid_lft forever preferred_lft forever
- inet6 ::1/128 scope host
- valid_lft forever preferred_lft forever
- 2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
- link/ether 00:50:56:3c:f8:dd brd ff:ff:ff:ff:ff:ff
- 3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond1 state UP qlen 1000
- link/ether 00:50:56:3c:72:c4 brd ff:ff:ff:ff:ff:ff
- 4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond2 state UP qlen 1000
- link/ether 00:50:56:2d:f6:f6 brd ff:ff:ff:ff:ff:ff
- 5: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
- link/ether ae:4e:20:a3:25:98 brd ff:ff:ff:ff:ff:ff
- 6: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
- link/ether 00:50:56:3c:f8:dd brd ff:ff:ff:ff:ff:ff
- inet 10.0.128.165/22 brd 10.0.131.255 scope global br-ex
- valid_lft forever preferred_lft forever
- inet6 fe80::250:56ff:fe3c:f8dd/64 scope link
- valid_lft forever preferred_lft forever
- 7: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
- link/ether 32:4f:6f:b0:37:4a brd ff:ff:ff:ff:ff:ff
- 8: br-tun: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
- link/ether fa:c3:7b:3f:40:40 brd ff:ff:ff:ff:ff:ff
- 9: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UP
- link/ether 00:50:56:3c:f8:dd brd ff:ff:ff:ff:ff:ff
- inet6 fe80::250:56ff:fe3c:f8dd/64 scope link
- valid_lft forever preferred_lft forever
- 10: bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
- link/ether 00:50:56:3c:72:c4 brd ff:ff:ff:ff:ff:ff
- inet6 fe80::250:56ff:fe3c:72c4/64 scope link
- valid_lft forever preferred_lft forever
- 11: bond2: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
- link/ether 00:50:56:2d:f6:f6 brd ff:ff:ff:ff:ff:ff
- inet6 fe80::250:56ff:fe2d:f6f6/64 scope link
- valid_lft forever preferred_lft forever
- 15: qbr1eace6ff-34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
- link/ether ae:65:4b:c3:3c:28 brd ff:ff:ff:ff:ff:ff
- inet6 fe80::b7:9cff:febc:41e6/64 scope link
- valid_lft forever preferred_lft forever
- [.....output abreviated....]
Then you'll get this:
- # lseth
- #PHYS STATE SPEED MTU DRIVER HW_Path MAC_Addr IP_Addr Description
- eth0 up 1000 1500 e1000 0000:02:02.0 00:50:56:3c:f8:dd N/A Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev
- eth1 up 1000 1500 e1000 0000:02:06.0 00:50:56:3c:72:c4 N/A Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev
- eth2 up 1000 1500 e1000 0000:02:07.0 00:50:56:2d:f6:f6 N/A Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev
- #VIRT STATE MTU DRIVER Active MAC IP_Addr Description
- bond0 up 1500 bonding (3.7.1) 00:50:56:3c:f8:dd N/A [ eth0 ]
- bond1 up 1500 bonding (3.7.1) 00:50:56:3c:72:c4 N/A [ eth1 ]
- bond2 up 1500 bonding (3.7.1) 00:50:56:2d:f6:f6 N/A [ eth2 ]
- br-ex up 1500 openvswitch (3.10.0-22...) 00:50:56:3c:f8:dd 10.0.128.165/22 N/A
- br-int (down) 1500 openvswitch (3.10.0-22...) 32:4f:6f:b0:37:4a N/A N/A
- br-tun (down) 1500 openvswitch (3.10.0-22...) fa:c3:7b:3f:40:40 N/A N/A
- ovs-system (down) 1500 openvswitch (3.10.0-22...) ae:4e:20:a3:25:98 N/A N/A
- qbr1eace6ff-34 up 1500 bridge (2.3) ae:65:4b:c3:3c:28 N/A N/A
- qbr6a35e050-ee up 1500 bridge (2.3) c6:bc:28:9c:2a:ce N/A N/A
- qbr7bf44648-c3 up 1500 bridge (2.3) ca:ff:e7:5e:f5:26 N/A N/A
- qbr35e0d8b2-83 up 1500 bridge (2.3) 6e:69:de:21:c8:9b N/A N/A
- qbr79f83edf-d8 up 1500 bridge (2.3) 86:f9:f5:90:a7:c7 N/A N/A
- qbr397526b7-44 up 1500 bridge (2.3) d6:7e:49:a6:32:53 N/A N/A
- qbrbd38c1c4-14 up 1500 bridge (2.3) fe:38:81:e8:32:03 N/A N/A
- qbrd5eb3687-5a up 1500 bridge (2.3) 8a:a1:75:a4:07:ab N/A N/A
- qvb1eace6ff-34 up 1500 veth (3.10.0-229.20.1) ae:65:4b:c3:3c:28 N/A N/A
- qvb6a35e050-ee up 1500 veth (3.10.0-229.20.1) c6:bc:28:9c:2a:ce N/A N/A
- qvb7bf44648-c3 up 1500 veth (3.10.0-229.20.1) ca:ff:e7:5e:f5:26 N/A N/A
- qvb35e0d8b2-83 up 1500 veth (3.10.0-229.20.1) 6e:69:de:21:c8:9b N/A N/A
- qvb79f83edf-d8 up 1500 veth (3.10.0-229.20.1) 86:f9:f5:90:a7:c7 N/A N/A
- qvb397526b7-44 up 1500 veth (3.10.0-229.20.1) d6:7e:49:a6:32:53 N/A N/A
- qvbbd38c1c4-14 up 1500 veth (3.10.0-229.20.1) fe:38:81:e8:32:03 N/A N/A
- qvbd5eb3687-5a up 1500 veth (3.10.0-229.20.1) 8a:a1:75:a4:07:ab N/A N/A
- qvo1eace6ff-34 up 1500 veth (3.10.0-229.20.1) 52:8a:42:c8:52:36 N/A N/A
- qvo6a35e050-ee up 1500 veth (3.10.0-229.20.1) 5a:0c:70:1b:4b:41 N/A N/A
- qvo7bf44648-c3 up 1500 veth (3.10.0-229.20.1) fa:65:75:82:17:dd N/A N/A
- qvo35e0d8b2-83 up 1500 veth (3.10.0-229.20.1) 52:9c:02:99:64:b4 N/A N/A
- qvo79f83edf-d8 up 1500 veth (3.10.0-229.20.1) 52:90:4c:c6:da:0b N/A N/A
- qvo397526b7-44 up 1500 veth (3.10.0-229.20.1) d6:51:d4:73:1e:e4 N/A N/A
- qvobd38c1c4-14 up 1500 veth (3.10.0-229.20.1) 7a:bf:ea:8c:44:8e N/A N/A
- qvod5eb3687-5a up 1500 veth (3.10.0-229.20.1) 22:30:00:96:b2:e7 N/A N/A
Here are a few other examples:
Simplistic RHEL6.7 system:
- # lseth
- #PHYS STATE SPEED MTU DRIVER HW_Path MAC_Addr IP_Addr Description
- eth0 up 1000 1500 igb 0000:03:00.0 d0:50:99:5b:da:72 N/A Intel Corporation I210 Gigabit Network Connection (rev 03)
- eth1 up 1000 1500 igb 0000:04:00.0 d0:50:99:5b:da:73 N/A Intel Corporation I210 Gigabit Network Connection (rev 03)
- eth2 up 1000 1500 ax88179_178a 3-4:1.0 00:24:9b:0b:de:10 N/A
- eth3 up 1000 1500 ax88179_178a 3-3:1.0 00:24:9b:13:26:7c N/A
- #VIRT STATE MTU DRIVER Active MAC IP_Addr Description
- bond0 up 1500 bonding (3.7.1) d0:50:99:5b:da:72 10.0.128.246/22 [ eth0 ]
- bond1 up 1500 bonding (3.7.1) d0:50:99:5b:da:73 172.17.1.102/24 [ eth1 ]
- bond2 up 1500 bonding (3.7.1) 00:24:9b:0b:de:10 N/A [ eth2 ]
- bond3 up 1500 bonding (3.7.1) 00:24:9b:13:26:7c N/A [ eth3 ]
- dummy0 (down) 1500 dummy (2.6.32-573.7.1) ce:eb:7d:e8:b6:0a N/A N/A
- dummy1 (down) 1500 dummy (2.6.32-573.7.1) 42:20:a0:f6:a1:62 N/A N/A
- vmnet2 up 1500 vmnet (2.6.32-573.7.1) 00:50:56:c0:00:02 10.128.16.1/24 N/A
- vmnet4 up 1500 vmnet (2.6.32-573.7.1) 00:50:56:c0:00:04 10.128.17.1/24 N/A
- vmnet6 up 1500 vmnet (2.6.32-573.7.1) 00:50:56:c0:00:06 10.128.18.1/24 N/A
Simplistic RHEL5 system:
- #PHYS STATE SPEED MTU DRIVER HW_Path MAC_Addr IP_Addr Description
- eth0 up 1000 1500 e1000 0000:02:00.0 00:0c:29:16:91:04 N/A Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev
- #VIRT STATE MTU DRIVER Active MAC IP_Addr Description
- bond0 up 1500 bonding (3.4.0-2) 00:0c:29:16:91:04 10.0.128.158/24 [ eth0 ]
It's still a very rough work in progress but I'd like to share it with all the good people here to get valuable input (would it be useful in your daily job?, RFE's, etc..)
Meanwhile, I already know I'll want to:
1) populate entries that are related to OVS and OVS-Bonds.
2) fix a few bugs (infiniband, etc..)
3) rewrite the whole thing in python to make it faster
4) add an option to explore the network namespaces and display interfaces underneath.
The current code can be downloaded here: https://raw.githubusercontent.com/ElCoyote27/krynn-tools/master/lseth
Ideas are most welcomed!
This comment has been removed by the author.
ReplyDeleteFor those interested, there is an excellent tool (now part of OSP7) to graphically display everything: plotnetcfg
ReplyDeletehttp://redhatstackblog.redhat.com/2015/10/15/troubleshooting-networking-with-rhel-openstack-platform-meet-plotnetcfg
Thanks, this is quite handy. I did find that the output might be wrong if the description variables weren't reset at the top of each loop. Here's the diff for how I fixed it:
ReplyDelete--- lseth 2017-10-11 10:10:16.076000000 -0700
+++ lseth.new 2017-10-11 10:02:45.580000000 -0700
@@ -77,7 +77,14 @@ do
if [ ! -f /sys/class/net/${mydev}/device ]; then
if [ "x${mydev}" != "x" ]; then
HWPATH="${mydev}/device"
- SPEED="N/A"
+ SPEED=""
+ STATE=""
+ MTU=0
+ SWDRIVER=""
+ PCIPATH=""
+ MCADDR=""
+ IPADDR=""
+ DESC=""
if [ -d ${HWPATH} ]; then
if [ $hstate -eq 0 ]; then
printf "\n${PHYS_PRINT_PATTERN}" "#PHYS" "STATE" "SPEED" "MTU" "DRIVER" "HW_Path" "MAC_Addr" "IP_Addr" "Description"
Cheers,
sln
Hi sln,
DeleteThanks for the fix, I uploaded a more recent version that includes your changes and a few others.
Cheers,
Vincent