码迷,mamicode.com
首页 > 其他好文 > 详细

统计网卡流量

时间:2017-05-22 19:01:42      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:nal   ifconfig   gre   ted   work   his   for   received   send   

#!/bin/bash

#This is the script for statistical traffic

Eth2_RX=$(ifconfig | grep -A8 eth2 | grep "RX" | tail -n 1 | awk -F ‘(‘ ‘{print $2}‘ | awk ‘{print $1}‘) Eth2_TX=$(ifconfig | grep -A8 eth2 | grep "RX" | tail -n 1 | awk -F ‘(‘ ‘{print $3}‘ | awk ‘{print $1}‘)

Eth4_RX=$(ifconfig | grep -A8 eth2 | grep RX | tail -n 1 | awk -F ‘(‘ ‘{print $2}‘ | awk ‘{print $1}‘) Eth4_TX=$(ifconfig | grep -A8 eth2 | grep RX | tail -n 1 | awk -F ‘(‘ ‘{print $3}‘ | awk ‘{print $1}‘)

Eth3_RX=$(ifconfig | grep -A 8 eth3 | grep "RX" | awk -F ‘(‘ ‘{print $2}‘ | awk ‘{print $1}‘) Eth3_TX=$(ifconfig | grep -A 8 eth3 | grep "RX" | awk -F ‘(‘ ‘{print $3}‘ | awk ‘{print $1}‘)

In_RX=`echo "$Eth2_RX+$Eth4_RX"|bc`

echo "The total internally accepted traffic is $In_RX "

In_TX=`echo "$Eth2_RX+$Eth4_RX"|bc`

echo "The total Internally sent traffic is

$In_TX" echo "The received traffic outside the network is $Eth3_RX"

echo "The outer network sends the flow is $Eth3_TX"

NetSave_RX=`echo "$In_RX-$Eth3_RX"|bc`

echo "The public network accepts traffic and saves $NetSave_RX"

NetSave_TX=`echo "$In_TX-$Eth3_TX"|bc`

echo "The public network sends traffic to saves $NetSave_TX"

统计网卡流量

标签:nal   ifconfig   gre   ted   work   his   for   received   send   

原文地址:http://www.cnblogs.com/guniang/p/6890802.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!