SSD lifetime status detection

Source: Internet
Author: 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? ###################################### 3. megacli =/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 =1 {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 = $ 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.