#!/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