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

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

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

復制代碼 代碼如下:

[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)容如下,幾乎不需要修改,就可以拿到任何機器上去使用了。
復制代碼 代碼如下:

[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)文章

最新評論

大英县| 察雅县| 商城县| 和静县| 宁明县| 右玉县| 锡林浩特市| 辉南县| 康乐县| 清涧县| 汨罗市| 沿河| 黄龙县| 新乡市| 曲阳县| 遵义县| 芦溪县| 康定县| 蓬安县| 佛冈县| 延边| 郓城县| 砀山县| 阳谷县| 陆河县| 来宾市| 靖西县| 黄浦区| 静海县| 永清县| 新竹市| 雷波县| 黄梅县| 临泉县| 嘉荫县| 株洲县| 淮滨县| 桐梓县| 湟中县| 罗山县| 得荣县|