码迷,mamicode.com
首页 > 其他好文 > 详细

检测硬盘

时间:2015-10-12 02:04:24      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:检测硬盘shell脚本

#!/bin/bash

#硬盘是否损坏(echo),i节点,硬盘空间使用率。

#If the harddrive is damaged (ECHO), the I-node, disk space usage.

CD=`df -l |awk‘NR==3 {print $4}‘|awk ‘BEGIN {FIELDWIDTHS="2 1"}‘‘{print $1}‘`

I=`df -i |awk‘NR==3 {print $3}‘`

DF=` df -l |awk‘NR==3 {print $3}‘`

DFG=`expr $DF /1048576`G

if [ -z $CD];then

        echo "unknow:disk";exit 3

else

        echo "1" > /tmp/disktest

        ET=`echo $?`

        if [ $ET -eq 0 ];then

                        if [ $I -ge 1000000];then

                                        if [ $CD-ge 80 ];then

                                               echo "Hard disk space is full, Hard disk usage is:$CD%, replace thehard disk";exit 2

                                                       elif [ $CD -ge 65 ];then

                                                        echo "Harddisk left is:$DFG, Hard disk usage is:$CD%";exit 1

                                                       else

                                                       echo "Hard disk is ok,Hard disk left is:$DFG";exit 0

                                                       fi

                        else

                        echo "I-nodes hasbeen exhausted, the remaining quantity is:$I ,replace the hard disk";exit2

                        fi

        else

        echo "The hard disk is damaged,replace the hard drive";exit 2

        fi

fi


本文出自 “运维之道” 博客,请务必保留此出处http://lrtao2010.blog.51cto.com/10425744/1701934

检测硬盘

标签:检测硬盘shell脚本

原文地址:http://lrtao2010.blog.51cto.com/10425744/1701934

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!