ilya-manin / tmux-network-bandwidth

📊 Network bandwidth plugin for tmux
MIT License
76 stars 13 forks source link

Does not work with netstat 1.42 #7

Closed harryqt closed 4 years ago

harryqt commented 4 years ago

I have two system one with Ubuntu 16.04 another is 18.04. The plugin works perfectly fine with 18.04 but does not seem to work 16.04

After investigating I found netstat -ie output is different.

Ubuntu 16.04 (netstat 1.42) returns:

harry@ubuntu16:~$ netstat -ie | awk '$0 ~ /(RX|TX) packets/'
          RX packets:4248959552 errors:0 dropped:0 overruns:14 frame:0
          TX packets:4015897634 errors:0 dropped:0 overruns:0 carrier:0
          RX packets:4066864 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4066864 errors:0 dropped:0 overruns:0 carrier:0

Ubuntu 18.04 (net-tools 2.10-alpha) returns:

harry@ubuntu18:~$ netstat -ie | awk '$0 ~ /(RX|TX) packets/'
        RX packets 1411505  bytes 1364845135 (1.3 GB)
        TX packets 811801  bytes 191044793 (191.0 MB)
        RX packets 2712  bytes 206035 (206.0 KB)
        TX packets 2712  bytes 206035 (206.0 KB)

Can you make the script compatible with both versions?

The full ouput of netstat -ie of older version of netstat is:

harry@ubuntu16:~$ netstat -ie
Kernel Interface table
enp1s0f0  Link encap:Ethernet  HWaddr 0c:c4:7a:82:4f:7e
          inet addr:185.00.00.69  Bcast:185.00.00.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4288373926 errors:0 dropped:0 overruns:14 frame:0
          TX packets:4050459290 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5100563461478 (5.1 TB)  TX bytes:5817812212633 (5.8 TB)
          Memory:88400000-8847ffff

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4157081 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4157081 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:9446777191 (9.4 GB)  TX bytes:9446777191 (9.4 GB)

harry@ubuntu16:~$
ilya-manin commented 4 years ago

Hey @Dibbyo456, please check out the new version.

harryqt commented 4 years ago

Thank you so much. One more thing; what needs to be change to get the output as megabits/s ?

ilya-manin commented 4 years ago

Well, it uses `numfmt' to format the amount of bytes, so it automatically scales. The first thing that comes to mind is that you can create your own function to convert bytes and add an option to the config to select the right base for conversion (in your case 1048576). Something like that. That would really help the development of this little plugin and open-source software in general.