Network Traffic Monitoring Tool 2 in Linux

Source: Internet
Author: User
Tags reverse dns

BecauseLinuxWe often need to check the traffic in Linux. The following three methods can solve the problem of checking the current traffic.

Iftop Tool
Purpose: monitors the network status and bandwidth used by each IP address in real time.

Iftop Official Website:
Http://www.ex-parrot.com /~ PDW/iftop/
Install iftop. libpcap must be installed first.
Http://www.tcpdump.org/release/
Wget http://www.tcpdump.org/release/libpcap-0.9.8.tar.gz
Tar-zxvf libpcap-0.9.8.tar.gz
CD libpcap-0.9.8
./Configure
Make; make install

After pcap is installed, install iftop again.
Wget http://www.ex-parrot.com /~ PDW/iftop/download/iftop-0.17.tar.gz
Tar zxvf iftop-0.17.tar.gz
CD iftop-0.17
./Configure
Make; make install

Monitor network card Traffic of eth1
# Iftop-I eth1

Traffic is displayed in bytes (by default, BITs ):
$ Iftop-B

The IP address is displayed directly without reverse DNS resolution:
$ Iftop-n

The connection port number is displayed directly, but the service name is not displayed:
$ Iftop-n

Display inbound and outbound traffic of a CIDR Block
$ Iftop-F 192.168.1.0/24 or 192.168.1.0/255.255.255.0

OthersParametersSee the description for iftop-H.

When you enter the iftop screen, you can press P to switch whether to display the connection port, N to switch to display the IP address or the domain name of the host, N to switch to display the connection port code or name, and P to suspend display, switch B to check whether the display bar is displayed. Switch B to calculate the average traffic in a few seconds. Other buttons can be clicked h to view the description.
Set the file location ~ /. Iftoprc. For details about how to set the file, refer to the info page of iftop.

Nload
Purpose: monitors the network status and bandwidth used by each IP address in real time.
The default nload is the eth0 Nic. If you want to monitor the traffic of the eth1 Nic
# Nload eth1
By default, nload is divided into two parts: the upper part is: Incoming, that is, the traffic into the NIC, the lower part is: outgoing, that is, the traffic from this Nic, each part includes the current traffic (curr), average traffic (avg), minimum traffic (min), maximum traffic (max), and total traffic (TTL, it looks quite intuitive.
In addition, you can also define the unit of Traffic Value display.
# Nload -- Help
You can see the specific parameters.

ViewNetworkAverage Traffic

The following script can monitor the average traffic of your network. 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/'$ ETH '://')
Outfirst = $ (awk '/' $ ETH '/{print $10}'/proc/NET/Dev)
Sumfirst = $ ($ infirst + $ outfirst ))
Sleep $ sec "S"
Inend = $ (awk '/' $ ETH '/{print $1}'/proc/NET/dev | SED's/'$ ETH '://')
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"

Bwbar
Purpose: To view the current traffic and bandwidth usage
Bwbar: http://www.kernel.org/bwbar.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.