Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 1333  / 2 Years ago, fri, august 26, 2022, 2:44:39

I want to get total amount of TX and RX to know the amount of data the server is receiving or transmitting at a moment.


With this command ip -s link I get this result


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes packets errors dropped overrun mcast
21914963679042 3114955121 0 0 0 0
TX: bytes packets errors dropped carrier collsns
21914963679042 3114955121 0 0 0 0
2: enp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether d4:5d:64:40:53:ca brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
251928745868 1094612700 0 0 0 5914052
TX: bytes packets errors dropped carrier collsns
1091337709507 1328468566 0 0 0 0
3: enp3s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether d4:5d:64:40:53:cb brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0

As far as I know, lo is local. So must be ignored. But I need to get the sum of TX an RX of remaining interfaces. How can it be done?


Thanks.


More From » networking

 Answers
1

I don't know if you need the ifupdown package installed, but you can install iftop to give you a live network view for current rates and stuff. It does cover internet as well as local connections happening.


sudo apt install iftop

You should run it with sudo


Example:


sudo iftop

12.5Kb 25.0Kb 37.5Kb 50.0Kb 62.5Kb
└───────────────┴───────────────┴───────────────┴───────────────┴───────────────
intrepid.home => Linksys04002.home 0b 0b 0b
<= 0b 424b 424b
239.255.255.250 => 169.254.7.236 0b 0b 0b
<= 1.85Kb 379b 95b
239.255.255.250 => 10.0.0.148 0b 0b 0b
<= 1.85Kb 379b 95b
224.0.0.251 => 10.0.0.172 0b 0b 0b
<= 0b 339b 498b
224.0.0.251 => 10.0.0.233 0b 0b 0b
<= 0b 322b 596b
255.255.255.255 => TY_WR.home 0b 0b 0b
<= 800b 320b 320b
224.0.0.251 => Chromecast.home 0b 0b 0b
<= 0b 314b 392b
10.0.0.255 => DESKTOP-DQO2D3U.home 0b 0b 0b
<= 0b 275b 393b
intrepid.home => 10.0.0.130 0b 0b 0b
<= 0b 257b 257b
────────────────────────────────────────────────────────────────────────────────
TX: cum: 19.4KB peak: 904b rates: 0b 260b 281b
RX: 74.8KB 18.8Kb 4.48Kb 3.96Kb 4.34Kb
TOTAL: 94.2KB 19.7Kb 4.48Kb 4.22Kb 4.61Kb

Or you can show only a specific interface like bond0


sudo iftop -i bond0

12.5Kb 25.0Kb 37.5Kb 50.0Kb 62.5Kb
└───────────────┴───────────────┴───────────────┴───────────────┴───────────────
intrepid.home => terrance-ubuntu.home 6.91Kb 6.05Kb 5.40Kb
<= 2.23Kb 1.84Kb 1.87Kb
239.255.255.250 => Linksys04002.home 0b 0b 0b
<= 0b 1.62Kb 828b
224.0.0.251 => 10.0.0.172 0b 0b 0b
<= 0b 1.02Kb 781b
224.0.0.251 => Chromecast.home 0b 0b 0b
<= 0b 953b 555b
intrepid.home => 10.0.0.148 0b 0b 0b
<= 0b 668b 668b
224.0.0.251 => 10.0.0.233 0b 0b 0b
<= 0b 645b 484b
10.0.0.255 => DESKTOP-DQO2D3U.home 0b 0b 0b
<= 976b 470b 442b
intrepid.home => Linksys04002.home 0b 0b 0b
<= 0b 424b 424b
intrepid.home => Chromecast.home 0b 0b 0b
<= 0b 395b 395b
────────────────────────────────────────────────────────────────────────────────
TX: cum: 70.5KB peak: 7.67Kb rates: 6.91Kb 6.34Kb 5.97Kb
RX: 93.0KB 26.8Kb 3.97Kb 10.4Kb 9.20Kb

To get the interface that is communicating with the internet it is the one that has the default gateway filled in. You can run netstat -rn to show all of the network(s) on that system. Below we can see that my gateway of 10.0.0.1 is on the bond0 interface.


terrance@Intrepid:~$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 bond0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 bond0
10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 bond0

Or ip route (thanks Doug :) ) will show the same gateway info:


terrance@Intrepid:~$ ip route
default via 10.0.0.1 dev bond0 onlink
10.0.0.0/24 dev bond0 proto kernel scope link src 10.0.0.220
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.1
169.254.0.0/16 dev bond0 scope link metric 1000

Adding in a screenshot here showing that it has bars on it to show which application(s) and which TX or RX is higher or lower.


enter image description here


You exit iftop by pressing either q or Ctrl+C on the keyboard.


[#170] Friday, August 26, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atelti

Total Points: 194
Total Questions: 129
Total Answers: 110

Location: North Korea
Member since Tue, Jun 16, 2020
4 Years ago
atelti questions
;