码迷,mamicode.com
首页 > 其他好文 > 详细

简单的实时监控脚本

时间:2018-04-10 21:53:26      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:####   free   tar   running   ace   color   function   ada   avg   

#!/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

 

简单的实时监控脚本

标签:####   free   tar   running   ace   color   function   ada   avg   

原文地址:https://www.cnblogs.com/rockley/p/8782367.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!