生活随笔
收集整理的這篇文章主要介紹了
监控网卡流量脚本
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
監控網卡流量腳本
|
|
|
? 前言:這個腳本是用來監控網卡的瞬時流量的,跟Cacti的計算結果完全吻合。如果想讓系統每多少分鐘取一次可以將此腳本改良成任務計劃執行的腳本并記錄到日志中。 ??? ? ??? #!/bin/bash ############################ ## ##? Author : Ajian ##? Time : 2007-9-21 ##? File:? netflood.sh ##? watch the eth0 or eth1 ################################# #Set the varible. ETH=eth0 while : ; do ??????? time=`date +%m"-"%d" "%k":"%M` ??????? day=`date +%m"-"%d` ??????? rx_before=`ifconfig $ETH|sed -n "8"p|awk '{print $2}'|cut -c7-` ??????? tx_before=`ifconfig $ETH|sed -n "8"p|awk '{print $6}'|cut -c7-` ??????? sleep 2 ??????? rx_after=`ifconfig $ETH|sed -n "8"p|awk '{print $2}'|cut -c7-` ??????? tx_after=`ifconfig $ETH|sed -n "8"p|awk '{print $6}'|cut -c7-` ??????? rx_result=$[(rx_after-rx_before)/256] ??????? tx_result=$[(tx_after-tx_before)/256] ??????? echo "$time Now_In_Speed: "$rx_result"kbps Now_OUt_Speed: "$tx_result"kbps" ??????? sleep 2 done |
|
|
轉載于:https://blog.51cto.com/makert/49396
總結
以上是生活随笔為你收集整理的监控网卡流量脚本的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。