Use Shell in Linux to monitor network traffic, and use linuxshell
#input the network name if [ -n "$1" ]; then eth_name=$1else eth_name="eth0"fi send_o=`ifconfig $eth_name | grep bytes | awk '{print $6}' | awk -F : '{print $2}'`recv_o=`ifconfig $eth_name | grep bytes | awk '{print $2}' | awk -F : '{print $2}'` se
Article Title: View your network using vnStat to monitor broadband traffic. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic categories. many articles have introduced how to monitor bandwidth in
I suddenly wanted to monitor the network card Traffic in Linux and didn't want to use cacti. I thought it was very troublesome to Configure SNMP. Ready-made tools seem to be useless. Decide to write a script by yourself.
Click (Here) Fold or open
#! /Bin/bash
Rx1 = $ (ifconfig $1 | grep "RX bytes" | awk '{print $2}' | awk-F: '{print $2 }')
Sleep 1
Rxa
In linux, tcpdump is used to monitor network traffic, and exported files are obtained to wireshark in windows to analyze the command lines in linux: tcpdump-I eth1-s 0 host 10.12.129.3-w output.txt-I indicates listening on eth1. The default value is eth0,This is not specified at the beginning, and the traffic of a cert
Linux with tcpdump network traffic monitoring, export files get windows with wireshark analysis linux command line: tcpdump-ieth1-s0host10121293-woutputtxt-i specified on eth1 listen, this according to different machines, by default, tcpdump is used in eth0 linux to monitor network
Use iftop to monitor network traffic
Iftop is a useful tool. The following command monitors the wireless network card of my notebook
Iftop-I wlan0
Basic description:
1. the main part of the screen is the data transfer between two machines, with an arrow indicating the direction. The three values on the right are
Nethogs is a small, free open source command-line tool used to count network bandwidth usage in real time by process or program.For use similar to "repo tool", "Depot_tools" and other tools checkout source code is very useful, you can view the current download speed information, so you do not blindly wait.Installation under Ubuntu system
sudo apt-get install Nethogs
How to use
Nethogs [-d] [-h] [-P] [-t] [-v] [device (s)]
#!/usr/bin/Envpython#-*-coding=utf-8-*-#Using GPL v2.7#Author: [email protected]126. Com#python Monitor network card traffic"""1, the realization principle: obtains the system information through the SNMP protocol, then carries on the corresponding computation and the format, the final output result2, special note: SNM
Use python to create a network card Traffic chart !!!
Project Background:
Using python to implement an automated network card Traffic chart, which gives us a deeper understanding of how to implement an automated O M platform,
It
This article introduces how to use Python to view network traffic information of the system. if you need it, you can refer to it for reference. Let's take a look.
Preface
The traffic information can be directly stored in/proc/net/devTo view, the program implemented by the author uses the command:
Sometimes we need a more real-time view of the network card traffic on the server, here I wrote two small script, one with the shell (first, only one network card can be viewed at a time), another in Python (after writing, can view more than one network card).
In the script
This article describes how to monitor network card traffic in python and use graphite graphics. For more information, see the following code:
#! /Usr/bin/env pythonImport sys, timeFrom socket import socketDef read_interface (in_file ):With file (in_file) as f:Return f. readlines () [2:]Def set_interface (inter_msg ):D
Preface
Traffic information can be directly in the /proc/net/dev view, the author implements the program to use the command:
Python net.py interface
Which interface is the name of the network card, what network card to use, the computer has what network card, you can use
Import RRDtoolImport timeCUR_TIME=STR (int (time.time ()))Rrd=rrdtool.create (' flow.rrd ', '--step ', ' a ', '--start ', Cur_time, #Flow. RRD filename,--step indicates how often the data is written, Start indicates the start time of the first record' Ds:eth0_in:counter:600:0:u ', #DS定义数据源, the network card eth0 into the traffic, COUNTER represents the increment (DST definition data type), followed by 600 s
Monitor linux traffic for shell and linux traffic for shell
If you want to view linux traffic in real time and do not want to go to a third-party tool, you can directly write and run it!
System: centos 6.5
Principle: Get the traffic from/proc/net/dev, and then get the
:
[program:monitor]command = python /usr/monitor/monitor.pydirectory = /usr/monitoruser = root
7.2. Operation Monitoring
Then run supervisord on the terminal to start the supervisor.Run supervisorctl on the terminal, go to shell, run status, and check the running status of the script.
7.3. disable monitoring and Common commands
The following commands are all executed in the shell of supervisorctl.
Shutdo
As an important equipment of network security, Rongteng network shunt is the most critical equipment of network monitoring front-end in the whole network security field. Today we detailed network traffic monitoring!
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.