最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

linux下監(jiān)控網(wǎng)絡(luò)流量的腳本

 更新時(shí)間:2013年01月23日 15:11:11   作者:  
在我們的日常工作當(dāng)中,監(jiān)控網(wǎng)絡(luò)要么使用iptarf,ifstat這些命令實(shí)現(xiàn)的,但是需要裝額外的RPM包。特別是iptarf裝起來麻煩
我看了下,linux下的/proc/net/dev記錄了每塊網(wǎng)卡發(fā)送和接受的包和字節(jié)數(shù)。因此萌生想法,寫了一個(gè)。運(yùn)行效果:

復(fù)制代碼 代碼如下:

[root@74-82-173-217 ~]# ./net.sh
Current Ip: inet addr:74.82.173.217 Bcast:74.82.173.223 Mask:255.255.255.224
Summry info: RX bytes:203692709 (194.2 MiB) TX bytes:93525930 (89.1 MiB)
eth0 Receive Bytes: 573 Packets: 3
eth0 Send Bytes: 3086 Packets: 3
eth0 Receive Bytes: 378 Packets: 7
eth0 Send Bytes: 11236 Packets: 7
eth0 Receive Bytes: 324 Packets: 6
eth0 Send Bytes: 444 Packets: 2
eth0 Receive Bytes: 54 Packets: 1
eth0 Send Bytes: 0 Packets: 0


具體腳本的內(nèi)容如下,幾乎不需要修改,就可以拿到任何機(jī)器上去使用了。
復(fù)制代碼 代碼如下:

[root@74-82-173-217 ~]# cat net.sh
#! /bin/bash
#Author: Vogts WangTao 2008-12-18
#Get summry info
echo "Current Ip: "`/sbin/ifconfig eth0 | grep inet`
echo "Summry info: "`/sbin/ifconfig eth0 | grep bytes`
#sleep 1 second ,monitor eth0
while true
do
receive1=`cat /proc/net/dev|grep eth0 | awk '{print$1}'|sed -s 's/eth0://g'`
receive_pack1=`cat /proc/net/dev|grep eth0 | awk '{print$2}'`
send1=`cat /proc/net/dev|grep eth0 | awk '{print$9}'`
send_pack1=`cat /proc/net/dev|grep eth0 | awk '{print$10}'`
sleep 1
receive2=`cat /proc/net/dev|grep eth0 | awk '{print$1}'|sed -s 's/eth0://g'`
receive_pack2=`cat /proc/net/dev|grep eth0 | awk '{print$2}'`
receive_cnt=`expr $receive2 - $receive1`
receive_pack_cnt=`expr $receive_pack2 - $receive_pack1`
send2=`cat /proc/net/dev|grep eth0 | awk '{print$9}'`
send_pack2=`cat /proc/net/dev|grep eth0 | awk '{print$10}'`
send_cnt=`expr $send2 - $send1`
send_pack_cnt=`expr $send_pack2 - $send_pack1`
echo 'eth0 Receive Bytes:' $receive_cnt ' Packets:' $receive_pack_cnt
echo 'eth0 Send Bytes:' $send_cnt ' Packets:' $send_pack_cnt
done

相關(guān)文章

最新評(píng)論

勃利县| 河东区| 临朐县| 内丘县| 舟山市| 砚山县| 临汾市| 休宁县| 耒阳市| 托克逊县| 赤城县| 江西省| 锡林浩特市| 岫岩| 永安市| 留坝县| 天长市| 调兵山市| 泰兴市| 丹东市| 堆龙德庆县| 滦平县| 登封市| 浏阳市| 漠河县| 和田县| 蓬莱市| 临夏市| 房山区| 新绛县| 昂仁县| 新邵县| 桃江县| 平利县| 启东市| 霍城县| 高陵县| 中方县| 达拉特旗| 河曲县| 延边|