shell 磁盘监控 shell脚本实现磁盘监控系统

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

shell 磁盘监控 shell脚本实现磁盘监控系统

高宏宇   2021-03-16 我要评论
想了解shell脚本实现磁盘监控系统的相关内容吗,高宏宇在本文为您仔细讲解shell 磁盘监控的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:shell,磁盘,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

效果如图:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们