熱門標簽:免費門店地圖標注注冊入駐
外呼系統(tǒng)一天耗費多少流量
電話機器人每天搜索多少次
艾比利外呼系統(tǒng)
陜西便宜電銷機器人軟件
杞縣地圖標注app
??谥悄苷Z音電銷機器人好用嗎
衡水外呼線路解決
昆明電話外呼系統(tǒng)好么
我看了下,linux下的/proc/net/dev記錄了每塊網卡發(fā)送和接受的包和字節(jié)數。因此萌生想法,寫了一個。運行效果:
復制代碼 代碼如下:
[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
具體腳本的內容如下,幾乎不需要修改,就可以拿到任何機器上去使用了。
復制代碼 代碼如下:
[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
您可能感興趣的文章:- linux 雙網卡綁定網絡設置方法
- Linux網絡編程之基于UDP實現可靠的文件傳輸示例
- Linux下用netstat查看網絡狀態(tài)、端口狀態(tài)
- linux命令學習之10個網絡命令和監(jiān)控命令
- 檢查linux網絡狀態(tài)的兩個腳本
- Linux基本網絡配置方法介紹
- Linux 檢測服務器是否連接著網絡
- Linux的常用網絡命令
- Linux下的網絡監(jiān)聽技術之一
- Linux模擬網絡丟包與延遲的方法
標簽:泰安
西寧
營口
宿遷
南京
昌都
臨滄
巨人網絡通訊聲明:本文標題《linux下監(jiān)控網絡流量的腳本》,本文關鍵詞 linux,下,監(jiān)控,網絡,流量,;如發(fā)現本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。