利用shell腳本實現每隔60秒磁盤內存數據監控腳本


#!/bin/bash
#Author:GaoHongYu
#QQ:1061767621
#Time:2019-12-24 18:43:22
#Name:ncjk.sh
#Version:V1.0
clear
xtip=$(hostname -I)
cprl=$(df -Th |head -2|tail -1|cut -d " " -f 10)
cpky=$(df -Th |head -2|tail -1|cut -d " " -f 12)
cpbfb=$(df -Th |head -2|tail -1|cut -d " " -f 18)
ncrl=$(free -m |head -2|tail -1|cut -d " " -f 13)
ncsy=$(free -m |head -2|tail -1|cut -d " " -f 22)
BC=$(echo "scale=2;$ncsy/$ncrl*100" |bc|cut -d "." -f 1) i
=1 while [ $i -le 60 ];do echo -e '\n' echo -e '\n' echo "-----磁盤監控系統-----" echo "--作者:Mr_GaoHongYu--" echo -n "監控本機IP地址:"$xtip echo -e '\n' echo "-----磁盤使用情況-----" echo -n "系統磁盤總容量:"$cprl echo -e '\n' echo -n "當前磁盤可用容量:"$cpky echo -e '\n' echo -n "可用容量百分比:"$cpbfb echo -e '\n' echo "-----內存使用情況-----" echo -n "內存總容量:"$ncrl echo -e '\n' echo -n "內存已使用:"$ncsy echo -e '\n' echo -n "內存已用百分比:" echo "$BC%" sleep 60 let i++ done

效果如圖:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM