查看所有網卡流量訊息腳本

版主: stnet253

回覆文章
admin
系統管理員
文章: 36
註冊時間: 2012-02-25, 22:10
聯繫:

查看所有網卡流量訊息腳本

未閱讀文章 admin »

ifconfig_info.sh

代碼: 選擇全部

#!/bin/bash
#./ifconfig_info.sh
cards=`ifconfig | grep "Link encap" | cut -d" " -f1`
i=0
echo
for card in $cards;do
    i=`expr $i + 1`
    rx_bytes=`ifconfig | grep "RX bytes" | sed -n "${i}p" | grep -Eo "RX bytes:[0-9]+" | grep -Eo "[0-9]+"`
    tx_bytes=`ifconfig | grep "TX bytes" | sed -n "${i}p" | grep -Eo "TX bytes:[0-9]+" | grep -Eo "[0-9]+"`
    echo "device=$card, rx_bytes=$rx_bytes, tx_bytes=$tx_bytes"
done;
echo
回覆文章

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 3 位訪客