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
  • 相关阅读:
    CSS 文本
    javascript:void(0)的问题
    剑指offer
    牛课--C/C++
    Linux学习--第二波
    面经-csdn
    初学Linux
    二分查找法的实现和应用汇总
    vs2013下git的使用
    win10+vs2013+Qt5.4 安装方法
  • 原文地址:https://www.cnblogs.com/gaoyuanzhi/p/8782367.html
Copyright © 2011-2022 走看看