zoukankan      html  css  js  c++  java
  • Linux系统下实时监控网口速率的shell脚本

    修改后的脚本文件

    #!/bin/bash
    #Modified by lifei4@datangmobile.cn
    echo ===DTmobile NetSpeedMonitor===
    sleep 1
    echo loading...
    sleep 1
    
    ethn=$1
     
    while true
    do
      RXpre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}')
      TXpre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}')
      sleep 1
      RXnext=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}')
      TXnext=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}')
     
      clear
      echo -e "			  RX 		   TX  			 TIME"
     
      RX=$((RXnext-RXpre))
      TX=$((TXnext-TXpre))
     
      if [ $RX -lt 1024 ];then
        RX="${RX}B/s"
      elif [ $RX -gt 1048576 ];then
        RX=$(echo $RX | awk '{print $1/1048576 "MB/s"}')
      else
        RX=$(echo $RX | awk '{print $1/1024 "KB/s"}')
      fi
     
      if [ $TX -lt 1024 ];then
        TX="${TX}B/s"
      elif [[ $TX -gt 1048576 ]];then
        TX=$(echo $TX | awk '{print $1/1048576 "MB/s"}')
      else
        TX=$(echo $TX | awk '{print $1/1024 "KB/s"}')
      fi
     
      echo -e "$ethn 	 $RX   $TX   			 `date +%k:%M:%S` "
     
    done
    

      

    源码来自网络,修改了16行

    用法

    ./NetSpeedMonitor.sh
    

      

    最终结果展示

  • 相关阅读:
    QPushbutton样式
    qt调动DLL
    QLabel设置行间距
    Qt 5.2.1 applications (32 bit) in CentOS (64 bit with gcc 4.8.2)
    qt设置阴影效果
    ubuntu命令
    How to configure NFS on Linux
    gsoap生成onvif c++源码
    QUrl乱码问题
    QTableWidget自适应标题(铺满、可调节)
  • 原文地址:https://www.cnblogs.com/phyger/p/9525410.html
Copyright © 2011-2022 走看看