这篇文章给大家分享的是有关shell脚本如何实现磁盘监控系统的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
利用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
效果如图:
感谢各位的阅读!关于“shell脚本如何实现磁盘监控系统”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://www.jb51.net/article/196553.htm