爲了檢測應用程序的效率,須要對服務器(Linux 無界面)上傳文件大量的文件,這時要查看服務器的動態網絡流量便成了麻煩事(使用nload以前),在網上DownLoad了一個nload-0.6.0.tar.tar解壓安裝報錯,通不過。以後要下了個nload-0.6.0-1-mdk92.i586.rpm格式的,一安裝,成了!
下載地址:http://sourceforge.net/project/showfiles.php?group_id=35865
nload-0.6.0-1-mdk92.i586.rpm的安裝命令 : rpm -ivh nload-0.6.0-1-mdk92.i586.rpm
nload-0.6.0.tar.tar的安裝方法:
1)tar -zxvf nload-0.6.0.tar.tar
2)cd ./bin
3)./configure --prefix=/usr/local/nload && make && make install
一樣能夠經過寫腳本的形式來查看流量,腳本以下:
#!/bin/bash
echo -n "請輸入須要查詢的網卡的接口:"
read eth
echo "你要查詢的網卡接口爲"$eth
echo -n "輸入須要等到的時間(秒):"
read sec
echo "你計算的是"$sec"秒內的平均流量"
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"秒內總流量爲:"$sum"bytes"
aver=$(($sum/$sec))
echo "平均流量爲:"$aver"bytes/sec"
nload默認的是eth0網卡,若是你想監測eth1網卡的流量:/usr/local/nload/bin/nload eth1php