How to share Linux traffic monitoring

Source: Internet
Author: User
Tags reverse dns

For Linux, we often need to check the traffic of Linux traffic monitoring. Linux traffic monitoring is still quite common. So I studied some methods of Linux traffic monitoring, I would like to share it with you here and hope it will be useful to you. The following three methods can be used to view the current traffic.

Iftop tool for Linux traffic monitoring

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

Run the command (must be root)
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

For other parameters, see 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 region ~ /. Iftoprc. You can refer to the info page of iftop if you set the limit method.

Linux traffic monitoring nload Tool

Purpose: monitors the network status and bandwidth used by each ip address in real time (nonsense)
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 has the current traffic Curr), average traffic Avg), minimum traffic Min), maximum traffic Max), and total traffic Ttl), which looks quite intuitive.
In addition, you can also define the unit of Traffic Value display.
# Nload -- help
You can see the specific parameters.

View average network 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"

  1. Management information library MIB in Linux SNMP) Learning
  2. There are two methods for collecting data in Linux SNMP:
  3. Seven BT download software collections in Linux
  4. Thirteen powerful Linux performance monitoring tools
  5. Learn Linux and FreeBSD to share swap partitions

Related Article

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.