巡检分区空间
常用脚本–分区空间
- #!/bin/bash
- #
- #********************************************************************
- #encoding -*-utf8-*-
- #Author: zhangshang
- #Date: 2017-11-25
- #URL: http://blog.vservices.top/myblog
- #Description: 检查磁盘占用率超过70%的分区,并显示出来
- #Copyright (C): 2017 All rights reserved
- #QQ Numbers: 765030447
- #********************************************************************
- echo -e "\033[31m***********************harddisk_check**************************\033[0m"
- #循环读取分区信息
- echo -e "Partition space information!"
- for i in `df -h | grep "\(\/dev\/sd\|\/$\)" | awk '{print $1,$5}' | cut -d% -f1 | tr -s '[:blank:]' ':'`
- do
- n=`echo $i | cut -d: -f2`
- h=`echo $i | cut -d: -f1`
- if [ "`echo $n `" -gt 70 ]
- then
- #超过报警阀值红色闪烁显示
- echo -e "Dev:$h\t\033[5;31mUsed:$n%\033[0m"
- else
- #正常显示旅社
- echo -e "Dev:$h\t\033[32mUsed:$n%\033[0m"
- fi
- done
- #循环读取分区Inode信息
- echo -e ""
- echo -e "Partition Inode information"
- for i in `df -ih | grep "\(\/dev\/sd\|\/$\)" | awk '{print $1,$5}' | cut -d% -f1 | tr -s '[:blank:]' ':'`
- do
- n=`echo $i | cut -d: -f2`
- h=`echo $i | cut -d: -f1`
- if [ "`echo $n `" -gt 70 ]
- then
- #超过报警阀值红色闪烁显示
- echo -e "Dev:$h\t\033[5;31mInodeUsed:$n%\033[0m"
- else
- #正常显示旅社
- echo -e "Dev:$h\t\033[32mInodeUsed:$n%\033[0m"
- fi
- done
显示效果结果:
- ***********************harddisk_check**************************
- Partition space information!
- Dev:/dev/mapper/centos_joker--7--01-root Used:9%
- Dev:/dev/sda1 Used:16%
- Partition Inode information
- Dev:/dev/mapper/centos_joker--7--01-root InodeUsed:1%
- Dev:/dev/sda1 InodeUsed:1%