The rapid development of Linux has caught up with Microsoft in just a short time, So Microsoft has paid attention to this opponent. Maybe you are learning Linux. Here we will explain how to check the script of Linux network port traffic, I hope to learn how to view the Linux network port traffic script. Through this script, we found that bash is indeed more powerful than the old shell in arithmetic operations. Therefore, we need to start learning bash to use its powerful functions. However, the for statement function in bash differs significantly from that in c.
- # Cat stream
-
- #! /Bin/bash
- # Write by Neil. xu qq: 37391319 email: xurongzhong@gmail.com
- #2008-8-19 we need to monitor streams of LTS channels, so write this
- Typeset in in_old dif_in dif_in1 dif_out1
- Typeset out out_old dif_out
-
- In_old= $ (Cat/proc/net/dev | grep eth0 | sed'S= ^ .*:= '| Awk' {print $1 }')
- Out_old= $ (Cat/proc/net/dev | grep eth0 | sed'S= ^ .*:= '| Awk' {print $9 }')
-
- While true
- Do
- Sleep 1
- In= $ (Cat/proc/net/dev | grep eth0 | sed'S= ^ .*:= '| Awk' {print $1 }')
- Out= $ (Cat/proc/net/dev | grep eth0 | sed'S= ^ .*:= '| Awk' {print $9 }')
- Dif_in= $ (In-in_old ))
- Dif_in1= $ (Dif_in * 8/1024/1024 ))
- Dif_out= $ (Out-out_old ))
- Echo "IN :$ {dif_in} bytes OUT :$ {dif_out} bytes"
- Dif_out1= $ (Dif_out * 8/1024/1024 ))
- Echo "IN :$ {dif_in1} mbps OUT :$ {dif_out1} mbps"
- In_old=$ {In}
- Out_old=$ {Out}
- Done
-
- Running effect:
- #./Stream
- IN: 349179 bytes OUT: 1363936 bytes
- IN: 2 mbps OUT: 10 mbps
- IN: 349612 bytes OUT: 1361852 bytes
- IN: 2 mbps OUT: 10 mbps
- IN: 348684 bytes OUT: 1358952 bytes
- IN: 2 mbps OUT: 10 mbps
- IN: 349998 bytes OUT: 1359092 bytes
In this way, you can learn how to view the Linux network port traffic.
- Analysis of Open-source Cisco router virtual machines in Linux
- 30 Linux releases
- Learning Experience: Linux File lock
- Linux Extension File System
- Easily create a file system in Linux