Linux檢視網路流量的指令碼
# cat stream
#! /bin/bash
# Write by Neil.xu qq:37391319 email:
# 2008-8-19 we need to monitor streams of LTS channels, so write this script
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
執行效果:# ./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: 2 mbps OUT: 10 mbps
本文出自:
或者直接使用以下命令查詢:
cat /proc/net/dev
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13879334/viewspace-1034750/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux下檢視當前網路流量Linux
- Linux檢視網路卡流量Linux
- Shell指令碼 – 檢視網路介面資訊指令碼
- linux網路流量實時監控指令碼Linux指令碼
- Win8 檢視無線網路流量
- linux檢視 CPU,記憶體,網路流量和磁碟 I/OLinux記憶體
- linux_監控網路卡流量指令碼Linux指令碼
- 如何檢視區域網內電腦網路流量
- linux 檢視網路埠Linux
- Linux檢視佔用swap的程式指令碼Linux指令碼
- Linux檢視網路卡流量方法的工具和命令彙總Linux
- 快速檢視LINUX 系統硬體的指令碼Linux指令碼
- linux 流量檢視工具 iftop 配置Linux
- Linux 中的網路指令:如何檢視一個域名有哪些 NS 記錄?Linux
- Linux檢視佔用記憶體的程式指令碼Linux記憶體指令碼
- 檢視ORACLE AS 埠指令碼Oracle指令碼
- linux下使用nload檢視網路卡實時流量(zt)Linux
- Linux網路命令與指令碼使用Linux指令碼
- rman的備份檢視的指令碼指令碼
- Linux 檢視網路連線狀態Linux
- linux檢視網路報文頻率Linux
- 在Linux中,如何檢視網路效能?Linux
- 檢視備份資訊指令碼指令碼
- 動態建立檢視指令碼指令碼
- 檢視鎖定的session資訊指令碼Session指令碼
- 【管理】Oracle 常用的V$ 檢視指令碼Oracle指令碼
- oracle 檢測指令碼on linuxOracle指令碼Linux
- Linux網路流量安全審計Linux
- 一個快速檢視trace的小指令碼指令碼
- 透過shell指令碼檢視procedure的資訊指令碼
- 透過shell指令碼檢視package的資訊指令碼Package
- 檢視空間使用情況的指令碼指令碼
- 通過shell指令碼檢視procedure的資訊指令碼
- 通過shell指令碼檢視package的資訊指令碼Package
- 檢視錶的統計資訊SQL指令碼SQL指令碼
- 網路視覺化:流量產業鏈上的王者視覺化產業
- Linux下針對伺服器網路卡流量和磁碟的監控指令碼Linux伺服器指令碼
- TCPView(檢視網路埠的程式)TCPView