首页 > 系统服务 > 详细

利用shell脚本实现每隔60秒磁盘内存数据监控脚本

时间:2019-12-24 21:13:58      阅读:245      评论:0      收藏:0      [点我收藏+]
#!/bin/bash
#Author:GaoHongYu
#QQ:1061767621
#Time:2019-12-24 18:43:22
#Name:ncjk.sh
#Version:V1.0
clear
xtip=$(ip a | grep "inet"|tail -1|cut -d " " -f 6)
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)
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 $((ncrl/ncsy))%
        sleep 60
    let i++
done

效果如图:

技术分享图片

利用shell脚本实现每隔60秒磁盘内存数据监控脚本

原文:https://www.cnblogs.com/gaohongyu/p/12093437.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!