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

Several methods of Linux Traffic Monitoring

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "several methods of Linux traffic monitoring". The content of 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 "several methods of Linux traffic monitoring".

Because it is often necessary to check the traffic of Linux traffic monitoring when doing Linux, Linux traffic monitoring is still more commonly used, so I studied some methods of Linux traffic monitoring and shared it with you here. I hope it will be useful to you. The following three methods can solve the current traffic view very well.

Iftop tools for Linux traffic monitoring

Purpose: used to monitor the network status and the bandwidth used by each ip in real time

Execute (must be as root)

Monitor the traffic of the network card of eth2

# iftop-I eth2

Display traffic in bytes (bytes) (the default is bit bits):

$iftop-B

Directly display IP, without DNS anti-solution:

$iftop-n

Directly display the port number, not the service name:

$iftop-N

Displays the inbound and outbound packet traffic of a network segment

$iftop-F 192.168.1.0 take 24 or 192.168.1.0 take 255.255.255.0

Other parameters can be described under iftop-h.

When entering the iftop screen, you can press p to switch whether to display the port, n to switch to display the IP or host domain name, N to switch to display the port code or name, p to pause the display, b to switch whether to display a long bar, B to switch to calculate the average flow within a few seconds, and other keys to press h to view the instructions.

The location of the profile is at ~ /. Iftoprc. For more information about profile modification, please refer to iftop's info page.

Nload tools for Linux traffic monitoring

Purpose: to monitor the status of the network and the bandwidth used by each ip in real time (nonsense)

Nload defaults to eth0 Nic. If you want to monitor the traffic of eth2 Nic,

# nload eth2

By default, nload is divided into two parts: the top part is the Incoming, that is, the traffic entering the Nic, and the lower part is the Outgoing, that is, the traffic outbound from this Nic. Each part has current traffic (Curr), average traffic (Avg), minimum traffic (Min), * * traffic (Max), and total traffic (Ttl), which looks quite intuitive.

In addition, you can also define the units in which traffic values are displayed.

# nload-help

You can see the specific relevant parameters.

View average network traffic

The following script can well monitor the average traffic of your network, and you can set the time.

#! / bin/bash

Echo-n "which nic?"

Read eth

Echo "the nic is" $eth

Echo-n "how much seconds:"

Read sec

Echo "duration is" $sec "seconds, wait please..."

Infirst=$ (awk'/'$eth'/ {print $1}'/ proc/net/dev | sed's raceme)

Outfirst=$ (awk'/'$eth'/ {print $10}'/ proc/net/dev)

Sumfirst=$ (($infirst+$outfirst))

Sleep $sec "s"

Inend=$ (awk'/'$eth'/ {print $1}'/ proc/net/dev | sed's raceme)

Outend=$ (awk'/'$eth'/ {print $10}'/ proc/net/dev)

Sumend=$ (($inend+$outend))

Sum=$ (($sumend-$sumfirst))

Echo $sec "seconds total:" $sum "bytes"

Aver=$ (($sum/$sec))

Echo "avrage:" $aver "bytes/sec"

Thank you for your reading, the above is the content of "several methods of Linux traffic monitoring". After the study of this article, I believe you have a deeper understanding of several methods of Linux traffic monitoring, 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

Servers

Wechat

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

12
Report