好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Shell腳本實現的單機流量統計功能

Shell腳本實現的單機流量統計功能

熱門標簽:杭州機器人外呼系統 旅游地圖標注大全 excel地址地圖標注 佛山高德地圖標注中心 地圖標注超出范圍怎么辦 東莞電銷機器人價格一覽表 百度地圖的地圖標注 百度地圖標注圖標更換 陜西電銷卡外呼系統怎么安裝

在網上看到這個單機流量的腳本,挺不錯的。

復制代碼 代碼如下:

#!/bin/sh
usage(){
echo “Usage: $0 [-i INTERFACE] [-s INTERVAL] [-c COUNT]”
echo
echo “-i INTERFACE”
echo “    The interface to monitor, default is eth0.”
echo “-s INTERVAL”
echo “    The time to wait in seconds between measurements, default is 3 seconds.”
echo “-c COUNT”
echo “    The number of times to measure, default is 10 times.”
exit 3
}
readargs(){
while [ "$#" -gt 0 ] ; do
  case “$1″ in
   -i)
    if [ "$2" ] ; then
     interface=”$2″
     shift ; shift
    else
     echo “Missing a value for $1.”
     echo
     shift
     usage
    fi
   ;;
   -s)
    if [ "$2" ] ; then
     sleep=”$2″
     shift ; shift
    else
     echo “Missing a value for $1.”
     echo
     shift
     usage
    fi
   ;;
   -c)
    if [ "$2" ] ; then
     counter=”$2″
     shift ; shift
    else
     echo “Missing a value for $1.”
     echo
     shift
     usage
    fi
   ;;
   *)
    echo “Unknown option $1.”
    echo
    shift
    usage
   ;;
  esac
done
}
checkargs(){
if [ ! "$interface" ] ; then
  interface=”eth0″
fi
if [ ! "$sleep" ] ; then
  sleep=”3″
fi
if [ ! "$counter" ] ; then
  counter=”10″
fi
}
printrxbytes(){
/sbin/ifconfig “$interface” | grep “RX bytes” | cut -d: -f2 | awk ‘{ print $1 }'
}
printtxbytes(){
/sbin/ifconfig “$interface” | grep “TX bytes” | cut -d: -f3 | awk ‘{ print $1 }'
}
bytestohumanreadable(){
multiplier=”0″
number=”$1″
while [ "$number" -ge 1024 ] ; do
  multiplier=$(($multiplier+1))
  number=$(($number/1024))
done
case “$multiplier” in
  1)
   echo “$number Kb”
  ;;
  2)
   echo “$number Mb”
  ;;
  3)
   echo “$number Gb”
  ;;
  4)
   echo “$number Tb”
  ;;
  *)
   echo “$1 b”
  ;;
esac
}
 
printresults(){
while [ "$counter" -ge 0 ] ; do
  counter=$(($counter – 1))
  if [ "$rxbytes" ] ; then
   oldrxbytes=”$rxbytes”
   oldtxbytes=”$txbytes”
  fi
  rxbytes=$(printrxbytes)
  txbytes=$(printtxbytes)
  if [ "$oldrxbytes" -a "$rxbytes" -a "$oldtxbytes" -a "$txbytes" ] ; then
   echo “$(/bin/date +%Y%m%d-%H%M%S) RXbytes = $(bytestohumanreadable $(($rxbytes – $oldrxbytes))) TXbytes = $(bytestohumanreadable $(($txbytes – $oldtxbytes)))”
  else
   echo “Monitoring $interface every $sleep seconds. (RXbyte total = $(bytestohumanreadable $rxbytes) TXbytes total = $(bytestohumanreadable $txbytes))”
  fi
  sleep “$sleep”
done
}
readargs “$@”
checkargs
printresults

測試如下:

每三秒的流量,總輸出999行,可以輸出到文件里,其中:前面為時間,Rx Packets 是接收數據包,即下載,Tx Packets 是發送數據包,即上傳.

復制代碼 代碼如下:

[root@host]#sh t.sh -c 999  Monitoring eth0 every 3 seconds. (RXbyte total = 6 Tb TXbytes total = 5 Tb)
20101105-201539 RXbytes = 126 Kb TXbytes = 658 Kb
20101105-201542 RXbytes = 87 Kb TXbytes = 487 Kb
20101105-201545 RXbytes = 159 Kb TXbytes = 668 Kb
20101105-201548 RXbytes = 107 Kb TXbytes = 725 Kb
20101105-201551 RXbytes = 110 Kb TXbytes = 704 Kb
20101105-201554 RXbytes = 90 Kb TXbytes = 726 Kb
20101105-201558 RXbytes = 100 Kb TXbytes = 850 Kb
20101105-201601 RXbytes = 102 Kb TXbytes = 703 Kb
20101105-201604 RXbytes = 168 Kb TXbytes = 693 Kb
20101105-201607 RXbytes = 105 Kb TXbytes = 730 Kb
20101105-201610 RXbytes = 133 Kb TXbytes = 711 Kb
20101105-201613 RXbytes = 431 Kb TXbytes = 703 Kb
20101105-201616 RXbytes = 84 Kb TXbytes = 527 Kb
20101105-201619 RXbytes = 239 Kb TXbytes = 825 Kb
20101105-201622 RXbytes = 117 Kb TXbytes = 801 Kb
20101105-201625 RXbytes = 99 Kb TXbytes = 913 Kb
20101105-201628 RXbytes = 89 Kb TXbytes = 322 Kb
20101105-201631 RXbytes = 63 Kb TXbytes = 73 Kb
20101105-201634 RXbytes = 84 Kb TXbytes = 191 Kb
20101105-201637 RXbytes = 174 Kb TXbytes = 481 Kb
20101105-201640 RXbytes = 120 Kb TXbytes = 383 Kb
20101105-201643 RXbytes = 94 Kb TXbytes = 496 Kb
20101105-201646 RXbytes = 108 Kb TXbytes = 340 Kb
20101105-201649 RXbytes = 91 Kb TXbytes = 639 Kb
20101105-201652 RXbytes = 106 Kb TXbytes = 629 Kb
20101105-201655 RXbytes = 125 Kb TXbytes = 496 Kb
20101105-201658 RXbytes = 90 Kb TXbytes = 537 Kb
20101105-201701 RXbytes = 114 Kb TXbytes = 641 Kb

標簽:西藏 朝陽 南充 隨州 青島 延邊 雅安 通遼

巨人網絡通訊聲明:本文標題《Shell腳本實現的單機流量統計功能》,本文關鍵詞  Shell,腳本,實現,的,單機,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Shell腳本實現的單機流量統計功能》相關的同類信息!
  • 本頁收集關于Shell腳本實現的單機流量統計功能的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 啊┅┅快┅┅用力啊岳| 老板办公室的调教h| 中文国产成人精品久久一区 | 欧美荷兰一区| 小sao货啊~啊h| 好吊淫| 老师脱??让学生摸??| 韩国三级HD中文字幕久久| 国产日韩欧美精品| 欧美伊人久久大香线蕉| 三上悠亚magnet| 老头扒开粉嫩小缝亲吻小说| XXX柔术做爰| 亚洲欧洲vat - 百度| 亚洲国产美女精品久久久久| 和八十老妇性欢过程| 九九亚洲综合精品自拍| 男人桶女人的鸡鸡| 美女扒开屁股让男人桶网站| 美女的胸免费视频网站| 精品视频在线观看免费网站| 亚洲高清视频一区| 一级A片国产高潮A片免看玉美人| 人妻制服视频一区二区宣宣影视 | 好大好爽我要喷水了(h)| 被粗大jib捣出了白浆H| 两个人的视频在线观看www免费| 日本一区二区不卡久久入口| 香蕉久久综合精品首页| 一攻n受h巨肉总攻| 高H公车全肉污文| 一女三黑人玩4p惨叫| 久久精品人人做人人看| 色老板在线看| 亚洲欧美中文日韩二区一区| www.EEUSS.com影院| 91丨九色丨国产丨PORNY | 浮力影院①线wy55www| 按摩逼| 国产福利小视频| 40岁丰满特级A片|