檢測硬碟

來源:互聯網
上載者:User

標籤:檢測硬碟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

檢測硬碟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.