SSD壽命狀態檢測

來源:互聯網
上載者:User
#!/bin/bash ###################################### Program for check SSD life .## if life < 80%  print Warning## if life < 60%  print Critical ## else Print OK#### Created  @ 2011-07-01 by Author .## Modified @ 2011-07-0X by Author ,  Why ?######################################3MEGACLI=/sbin/megacliSMARTCTL=/usr/local/sbin/smartctlDeviceidlist=”"get_deviceid(){TMPFILE=tmp_ssdstat.$$$MEGACLI -PDList -aALL > $TMPFILElineinfo=($(grep -n “Device Id”  $TMPFILE | awk -F ‘:’ ‘{print $3″:”$1}’))linecnt=$[ ${#lineinfo[*]} -1 ]Deviceidlist=”"if [ ${linecnt} -ge 1 ] ; thenfor id in $(seq 0  ${linecnt}  )o  id1=id  id2=$[$id +1]  info1=${lineinfo[$id1]}  if [ ${id} -ne $linecnt ] ;  then    info2=${lineinfo[$id2]}  else    info2=L:$(cat $TMPFILE | wc -l)  fi  ## echo $info1,$info2  linenum1=$(echo $info1 | awk -F ‘:’ ‘{print $2}’)  DeviceID=$(echo $info1 | awk -F ‘:’ ‘{print $1}’)  linenum2=$(echo $info2 | awk -F ‘:’ ‘{print $2}’)  SSDCNT=$(sed -n “${linenum1},${linenum2} p” $TMPFILE | grep “Inquiry Data” | grep SSD | wc -l)  if [ $SSDCNT -ne 0 ] ; then        Deviceidlist=”$Deviceidlist ${DeviceID}”   fidonefi/bin/rm -f $TMPFILE} get_deviceidWarning=falseCritical=falsefor Devid in $Deviceidlistdo        LIFE=$( $SMARTCTL -a -d megaraid,${Devid} /dev/sda | grep Media_Wearout_Indicator | awk ‘{print $4}’)        Lifevalue=$[ 10#$LIFE + 0 ]        resString=”"        if [ $Lifevalue -le 60 ]; then                Critical=True                resString=”::${resString}Dev${Devid}=${Lifevalue}”        elif [ $Lifevalue -le 80 ] ; then                Warning=True                resString=”::${resString}Dev${Devid}=${Lifevalue}”        fidoneif $Critical ; then        echo “Critical-SSD_Life${resString}”elif $Warning  ; then        echo “Warning-SSD_Life${resString}”else        echo “OK”fiexit 0

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.