Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commonly used network monitors in Linux

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what are the commonly used network monitors in Linux". The explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what network monitors are commonly used in Linux.

Iftop

Iftop listens on the network interface you specify and displays the connection in the form of top.

This is a good gadget for quickly identifying occupancy, measuring speed, and maintaining the overall operation of network traffic. It's amazing to see how much bandwidth we use, especially for those of us who remember to use phone lines, modems, screaming Kbit speeds and real real-time baud rates. We gave up the baud rate a long time ago and switched to the bit rate. The baud rate measurement signal changes, sometimes the same as the bit rate, but in most cases it is not.

If you have only one network interface, you can run iftop without options. Iftop requires root permission:

$sudo iftop

When you have multiple interfaces, specify the interfaces to monitor:

$sudo iftop-I wlan0

Just like top, you can change the display options at runtime.

H toggles the help screen. N Toggle name resolution. S switch source host display, d switch destination host. S switch the port number. N toggle port resolution. To see all the port numbers, turn off parsing. T switch the text interface. Ncurses is required for the default display. I think the text display is easier to read and better organized (figure 1). P pauses the display. Q exit the program.

Figure 1: the text display is readable and organized.

When you switch display options, iftop will continue to measure all traffic. You can also select a single host to monitor. You need the IP address and network mask of the host. I was curious about how much Pandora took up in my poor bandwidth, so I first used dig to find their IP addresses:

$dig A pandora.com [...]; ANSWER SECTION:pandora.com. 267 IN A 208.85.40.20pandora.com. 267 IN A 208.85.40.50

What is the network mask? Ipcalc tells us:

$ipcalc-b 208.85.40.20Address: 208.85.40.20Netmask: 255.255.255.0 = 24Wildcard: 0.0.255 = > Network: 208.85.40.0 pound 24

Now provide the address and netmask to iftop:

$sudo iftop-F 208.85.40.20max 24-I wlan0

Isn't that true? I was surprised to find that my precious bandwidth is ample for Pandora, using about 500Kb per hour. And, like most streaming services, Pandora has spikes in traffic, which rely on caching to ease congestion.

You can use the-G option to do the same for the IPv6 address. Refer to the man page for other features of iftop, including customizing default options using custom profiles and applying custom filters (see PCAP-FILTER as filter reference).

Nethogs

Nethogs is fast and easy when you want to quickly find out who is taking up your bandwidth. Run as root and specify the interface to listen on. It shows the free application and process number so that you can kill it if you like:

$sudo nethogs wlan0NetHogs version 0.8.1PID USER PROGRAM DEV SENT RECEIVED7690 carla / usr/lib/firefox wlan0 12.494 556.580 KB/sec5648 carla... / chromium-browser wlan0 0.052 0.038 KB/secTOTAL 12.546 556.618 KB/sec

There are few Nethogs options: loop between kb/s, kb, b, and mb; sort by packets received or sent; and adjust the delay between refreshes. See man nethogs, or run nethogs-h.

Vnstat

Vnstat is the easiest network data collector to use. It is lightweight and does not require root permissions. It runs as a daemon and records your network statistics. The vnstat command displays cumulative data:

$vnstat-I wlan0Database updated: Tue Oct 17 08:36:38 2017wlan0 since 10/17/2017rx: 45.27 MiB tx: 3.77 MiB total: 49.04 MiBmonthlyrx | tx | total | avg. Rate----+-Oct'17 45.27 MiB | 3.77 MiB | 49.04 MiB | 0.28 kbit/s----+-- -+-estimated 85 MiB | 5 MiB | 90 MiB | dailyrx | tx | total | avg. Rate----+-today 45.27 MiB | 3.77 MiB | 49.04 MiB | 12.96 kbit/s----+ -+-estimated 125 MiB | 8 MiB | 133 MiB |

It displays all network interfaces by default. Use the-I option to select a single interface. Merge data from multiple interfaces in this way:

$vnstat-I wlan0+eth0+eth2

You can filter the display in the following ways:

-h displays statistics in hours. -d displays statistics in days. -w and-m display statistics by week and month. Use the-l option to view live updates. This command deletes the database for wlan1 and stops monitoring it:

$vnstat-I wlan1-- delete

This command creates an alias for the network interface. This example uses a strange interface name in Ubuntu 16.04:

$vnstat-u-I enp0s25-- nick eth0

By default, vnstat monitors eth0. You can change this in / etc/vnstat.conf or create your own personal profile in the home directory. See man vnstat for a complete reference.

You can also install vnstati to create a simple color diagram (figure 2):

$vnstati-s-I wlx7cdd90a0a1c2-o vnstat.png

Figure 2: you can use vnstati to create simple color charts.

Thank you for your reading, the above is the content of "what are the network monitors commonly used in Linux". After the study of this article, I believe you have a deeper understanding of what the network monitors commonly used in Linux have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report