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:
  1. # ip a s  
  2. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN  
  3.     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
  4.     inet 127.0.0.1/8 scope host lo  
  5.        valid_lft forever preferred_lft forever  
  6.     inet6 ::1/128 scope host  
  7.        valid_lft forever preferred_lft forever  
  8. 2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000  
  9.     link/ether 00:50:56:3c:f8:dd brd ff:ff:ff:ff:ff:ff  
  10. 3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond1 state UP qlen 1000  
  11.     link/ether 00:50:56:3c:72:c4 brd ff:ff:ff:ff:ff:ff  
  12. 4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond2 state UP qlen 1000  
  13.     link/ether 00:50:56:2d:f6:f6 brd ff:ff:ff:ff:ff:ff  
  14. 5: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN  
  15.     link/ether ae:4e:20:a3:25:98 brd ff:ff:ff:ff:ff:ff  
  16. 6: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN  
  17.     link/ether 00:50:56:3c:f8:dd brd ff:ff:ff:ff:ff:ff  
  18.     inet 10.0.128.165/22 brd 10.0.131.255 scope global br-ex  
  19.        valid_lft forever preferred_lft forever  
  20.     inet6 fe80::250:56ff:fe3c:f8dd/64 scope link  
  21.        valid_lft forever preferred_lft forever  
  22. 7: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN  
  23.     link/ether 32:4f:6f:b0:37:4a brd ff:ff:ff:ff:ff:ff  
  24. 8: br-tun: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN  
  25.     link/ether fa:c3:7b:3f:40:40 brd ff:ff:ff:ff:ff:ff  
  26. 9: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UP  
  27.     link/ether 00:50:56:3c:f8:dd brd ff:ff:ff:ff:ff:ff  
  28.     inet6 fe80::250:56ff:fe3c:f8dd/64 scope link  
  29.        valid_lft forever preferred_lft forever  
  30. 10: bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP  
  31.     link/ether 00:50:56:3c:72:c4 brd ff:ff:ff:ff:ff:ff  
  32.     inet6 fe80::250:56ff:fe3c:72c4/64 scope link  
  33.        valid_lft forever preferred_lft forever  
  34. 11: bond2: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP  
  35.     link/ether 00:50:56:2d:f6:f6 brd ff:ff:ff:ff:ff:ff  
  36.     inet6 fe80::250:56ff:fe2d:f6f6/64 scope link  
  37.        valid_lft forever preferred_lft forever  
  38. 15: qbr1eace6ff-34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP  
  39.     link/ether ae:65:4b:c3:3c:28 brd ff:ff:ff:ff:ff:ff  
  40.     inet6 fe80::b7:9cff:febc:41e6/64 scope link  
  41.        valid_lft forever preferred_lft forever  
  42. [.....output abreviated....]  

Then you'll get this:
  1. # lseth   
  2.   
  3.   
  4. #PHYS  STATE  SPEED   MTU DRIVER        HW_Path       MAC_Addr                IP_Addr              Description  
  5. 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  
  6. 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  
  7. 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  
  8.   
  9.   
  10. #VIRT             STATE   MTU DRIVER                     Active MAC              IP_Addr              Description  
  11. bond0                up  1500 bonding (3.7.1)            00:50:56:3c:f8:dd       N/A                  [ eth0 ]  
  12. bond1                up  1500 bonding (3.7.1)            00:50:56:3c:72:c4       N/A                  [ eth1 ]  
  13. bond2                up  1500 bonding (3.7.1)            00:50:56:2d:f6:f6       N/A                  [ eth2 ]  
  14. br-ex                up  1500 openvswitch (3.10.0-22...) 00:50:56:3c:f8:dd       10.0.128.165/22      N/A  
  15. br-int           (down)  1500 openvswitch (3.10.0-22...) 32:4f:6f:b0:37:4a       N/A                  N/A  
  16. br-tun           (down)  1500 openvswitch (3.10.0-22...) fa:c3:7b:3f:40:40       N/A                  N/A  
  17. ovs-system       (down)  1500 openvswitch (3.10.0-22...) ae:4e:20:a3:25:98       N/A                  N/A  
  18. qbr1eace6ff-34       up  1500 bridge (2.3)               ae:65:4b:c3:3c:28       N/A                  N/A  
  19. qbr6a35e050-ee       up  1500 bridge (2.3)               c6:bc:28:9c:2a:ce       N/A                  N/A  
  20. qbr7bf44648-c3       up  1500 bridge (2.3)               ca:ff:e7:5e:f5:26       N/A                  N/A  
  21. qbr35e0d8b2-83       up  1500 bridge (2.3)               6e:69:de:21:c8:9b       N/A                  N/A  
  22. qbr79f83edf-d8       up  1500 bridge (2.3)               86:f9:f5:90:a7:c7       N/A                  N/A  
  23. qbr397526b7-44       up  1500 bridge (2.3)               d6:7e:49:a6:32:53       N/A                  N/A  
  24. qbrbd38c1c4-14       up  1500 bridge (2.3)               fe:38:81:e8:32:03       N/A                  N/A  
  25. qbrd5eb3687-5a       up  1500 bridge (2.3)               8a:a1:75:a4:07:ab       N/A                  N/A  
  26. qvb1eace6ff-34       up  1500 veth (3.10.0-229.20.1)     ae:65:4b:c3:3c:28       N/A                  N/A  
  27. qvb6a35e050-ee       up  1500 veth (3.10.0-229.20.1)     c6:bc:28:9c:2a:ce       N/A                  N/A  
  28. qvb7bf44648-c3       up  1500 veth (3.10.0-229.20.1)     ca:ff:e7:5e:f5:26       N/A                  N/A  
  29. qvb35e0d8b2-83       up  1500 veth (3.10.0-229.20.1)     6e:69:de:21:c8:9b       N/A                  N/A  
  30. qvb79f83edf-d8       up  1500 veth (3.10.0-229.20.1)     86:f9:f5:90:a7:c7       N/A                  N/A  
  31. qvb397526b7-44       up  1500 veth (3.10.0-229.20.1)     d6:7e:49:a6:32:53       N/A                  N/A  
  32. qvbbd38c1c4-14       up  1500 veth (3.10.0-229.20.1)     fe:38:81:e8:32:03       N/A                  N/A  
  33. qvbd5eb3687-5a       up  1500 veth (3.10.0-229.20.1)     8a:a1:75:a4:07:ab       N/A                  N/A  
  34. qvo1eace6ff-34       up  1500 veth (3.10.0-229.20.1)     52:8a:42:c8:52:36       N/A                  N/A  
  35. qvo6a35e050-ee       up  1500 veth (3.10.0-229.20.1)     5a:0c:70:1b:4b:41       N/A                  N/A  
  36. qvo7bf44648-c3       up  1500 veth (3.10.0-229.20.1)     fa:65:75:82:17:dd       N/A                  N/A  
  37. qvo35e0d8b2-83       up  1500 veth (3.10.0-229.20.1)     52:9c:02:99:64:b4       N/A                  N/A  
  38. qvo79f83edf-d8       up  1500 veth (3.10.0-229.20.1)     52:90:4c:c6:da:0b       N/A                  N/A  
  39. qvo397526b7-44       up  1500 veth (3.10.0-229.20.1)     d6:51:d4:73:1e:e4       N/A                  N/A  
  40. qvobd38c1c4-14       up  1500 veth (3.10.0-229.20.1)     7a:bf:ea:8c:44:8e       N/A                  N/A  
  41. 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:
  1. # lseth  
  2.   
  3.   
  4. #PHYS  STATE  SPEED   MTU DRIVER        HW_Path       MAC_Addr                IP_Addr              Description  
  5. 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)  
  6. 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)  
  7. eth2      up   1000  1500 ax88179_178a  3-4:1.0       00:24:9b:0b:de:10       N/A                   
  8. eth3      up   1000  1500 ax88179_178a  3-3:1.0       00:24:9b:13:26:7c       N/A                   
  9.   
  10.   
  11. #VIRT     STATE   MTU DRIVER                             Active MAC              IP_Addr              Description  
  12. bond0        up  1500 bonding (3.7.1)                    d0:50:99:5b:da:72       10.0.128.246/22      [ eth0 ]  
  13. bond1        up  1500 bonding (3.7.1)                    d0:50:99:5b:da:73       172.17.1.102/24      [ eth1 ]  
  14. bond2        up  1500 bonding (3.7.1)                    00:24:9b:0b:de:10       N/A                  [ eth2 ]  
  15. bond3        up  1500 bonding (3.7.1)                    00:24:9b:13:26:7c       N/A                  [ eth3 ]  
  16. dummy0   (down)  1500 dummy (2.6.32-573.7.1)             ce:eb:7d:e8:b6:0a       N/A                  N/A  
  17. dummy1   (down)  1500 dummy (2.6.32-573.7.1)             42:20:a0:f6:a1:62       N/A                  N/A  
  18. vmnet2       up  1500 vmnet (2.6.32-573.7.1)             00:50:56:c0:00:02       10.128.16.1/24       N/A  
  19. vmnet4       up  1500 vmnet (2.6.32-573.7.1)             00:50:56:c0:00:04       10.128.17.1/24       N/A  
  20. 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:
  1. #PHYS  STATE  SPEED   MTU DRIVER        HW_Path       MAC_Addr                IP_Addr              Description  
  2. 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  
  3.   
  4. #VIRT    STATE   MTU DRIVER                              Active MAC              IP_Addr              Description  
  5. 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.


Ideas are most welcomed!

Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. For those interested, there is an excellent tool (now part of OSP7) to graphically display everything: plotnetcfg
    http://redhatstackblog.redhat.com/2015/10/15/troubleshooting-networking-with-rhel-openstack-platform-meet-plotnetcfg

    ReplyDelete
  3. 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:

    --- 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

    ReplyDelete
    Replies
    1. Hi sln,
      Thanks for the fix, I uploaded a more recent version that includes your changes and a few others.
      Cheers,
      Vincent

      Delete

Post a Comment

Popular posts from this blog

LSI MegaRaid HBA's, overheating and one ugly hack

Some Tips about running a Dell PowerEdge Tower Server as your workstation

VMWare Worksation 12 on Fedora Core 23/24 (fc23 and fc24)