zoukankan      html  css  js  c++  java
  • 简单的实时监控脚本

    #!/bin/bash
    while true;do
    net=($(egrep -v "(lo|face|Inter-)" /proc/net/dev | awk -F ":" '{print $1}'))
    RTstart=($(egrep -v "(lo|face|Inter-)" /proc/net/dev | awk '{print $2,$10}'))
    sleep 1
    clear
    RTstop=($(egrep -v "(lo|face|Inter-)" /proc/net/dev | awk '{print $2,$10}'))
    Rspeed=$(( ${RTstop[0]} - ${RTstart[0]} ))
    Tspeed=$(( ${RTstop[1]} - ${RTstart[1]} ))
    function speed(){
    if [[ $1 -gt 1048576 ]];then
            speed=$(echo "scale=2; $1 / 1048576" | bc)
            echo -e "$2    : ${speed}  M/s "
    elif [[ $1 -gt 1024 ]];then
            speed=$(echo "scale=2; $1 / 1024" | bc)
            echo -e "$2    : ${speed} K/s "
    else
            speed=$1
            echo -e "$2    : ${speed} B/s "
    
    fi
    }
    echo "#################################"
    echo "#eth     : $net"
    echo "#$(speed $Rspeed "Down")"
    echo "#$(speed $Tspeed "UP  ")"
    echo "#RUNNING : $(uptime -s)"
    echo "#SINCE   : $(uptime -p)"
    echo "#CPULoad : $(awk '{print $1,$2,$3}' /proc/loadavg)"
    echo "#$(free -h | awk '/Mem/ {print "MemUsed : "$3"/"$2}')"
    echo "#################################"
    sleep 4
    done
  • 相关阅读:
    Java第七次作业
    JAVA第六次作业
    JAVA第五次作业
    JAVA第四次作业
    JAVA第三次作业
    JAVA第二次作业
    Java第一次作业
    2017《Java》预备作业02 计科1501刘喆
    2017《JAVA》预备作业 计科1501刘喆
    Java第十次作业--多线程
  • 原文地址:https://www.cnblogs.com/gaoyuanzhi/p/8782367.html
Copyright © 2011-2022 走看看