linux網絡卡流量檢測工具

2021-06-07 20:14:28 字數 2701 閱讀 9138

檔案說明:

streak.sh:以「k」為流量單位的linux網絡卡檢測工具。

stream.sh:以「m」為流量單位的linux網絡卡檢測工具。

使用方法:

chmod a+x streak.sh stream.sh

./streak.sh或./stream.sh

工具說明:

此工具擷取了linux系統資料夾/proc/net/dev中的網絡卡部分資訊並按格式列印。

列印結果與下一次取值進行對比,對比時間間隔為1秒。

並將取值進行單位換算,得到以k或m為單位的輸出。

加入了read讀取網口的環境變數,減小了工作量。

#! /bin/bash

read -p "enter your net port:[eth0|eth1|eth2]" ifcfg

typeset in in_old dif_in dif_in1 dif_out1

typeset out out_old dif_out

in_old=$(cat /proc/net/dev | grep $ifcfg | sed 's=^.*:==' | awk '' )

out_old=$(cat /proc/net/dev | grep $ifcfg | sed 's=^.*:==' | awk '')

while true

do sleep 1

in=$(cat /proc/net/dev | grep $ifcfg | sed 's=^.*:==' | awk '')

out=$(cat /proc/net/dev | grep $ifcfg | sed 's=^.*:==' | awk '')

dif_in=$((in-in_old))

dif_in1=$((dif_in * 8 / 1024 ))

dif_out=$((out-out_old))

echo " in: $ bytes out: $ bytes "

dif_out1=$((dif_out * 8 / 1024 ))

echo "in: $ kbps out: $ kbps"

in_old=$

out_old=$

done

#執行效果:

# ./streak.sh

in: 349179 bytes out: 1363936 bytes

#in: 2 kbps out: 10 kbps

in: 349612 bytes out: 1361852 bytes

#in: 2 kbps out: 10 kbps

in: 348684 bytes out: 1358952 bytes

#in: 2 kbps out: 10 kbps

in: 349998 bytes out: 1359092 bytes

#! /bin/bash

read -p "enter your net port:[eth0|eth1|eth2]" ifcfg

typeset in in_old dif_in dif_in1 dif_out1

typeset out out_old dif_out

in_old=$(cat /proc/net/dev | grep $ifcfg | sed  's=^.*:==' | awk '' )

out_old=$(cat /proc/net/dev | grep $ifcfg | sed  's=^.*:=='  | awk '')

while true

do         sleep 1

in=$(cat /proc/net/dev | grep $ifcfg | sed  's=^.*:=='  | awk '')

out=$(cat /proc/net/dev | grep $ifcfg | sed  's=^.*:=='  | awk '')

dif_in=$((in-in_old))

dif_in1=$((dif_in * 8 / 1024 /1024 ))

dif_out=$((out-out_old))

echo "                                         in: $ bytes     out: $ bytes "

dif_out1=$((dif_out * 8 / 1024 /1024 ))

echo "in: $ mbps    out: $ mbps"

in_old=$

out_old=$

done

#執行效果:

# ./stream.sh

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

Linux 效能檢測工具 FREE

free name free 顯示系統可用記憶體和已使用記憶體 語法 free b k m o s delay t l v 描述 free 顯示了總可用和被用的物理記憶體和 swap 記憶體,也包括核心使用的 buffer shared memory 已經被廢棄 選項 b k m b 以位元組為單位...

linux 效能檢測工具之 dstat

這幾天在做lamp效能調優,對系統效能檢測使用top vmstat 發現非常不妨便,在剛開會的時候,mandahang 介紹了乙個軟體 dstat,用起來感覺還真不錯。下面則對dstat 做下簡單的介紹 一 安裝 1.在centos下 可以 yum y instatll dstat wget rpm...

Valgrind 記憶體檢測工具

valgrind是乙個gpl的軟體,用於linux for x86,amd64 and ppc32 程式的記憶體除錯和 剖析。你可以在它的環境中執行你的程式來監視記憶體的使用情況,比如c 語言中的malloc和free或者 c 中的new和 delete。使用valgrind的工具包,你可以自動的檢...