zoukankan      html  css  js  c++  java
  • SSD寿命状态检测

    #!/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/megacli
    SMARTCTL=/usr/local/sbin/smartctl
    Deviceidlist=”"
    get_deviceid()
    {
    TMPFILE=tmp_ssdstat.$$
    $MEGACLI -PDList -aALL > $TMPFILE
    lineinfo=($(grep -n “Device Id”  $TMPFILE | awk -F ‘:’ ‘{print $3″:”$1}’))
    linecnt=$[ ${#lineinfo[*]} -1 ]
    Deviceidlist=”"
    if [ ${linecnt} -ge 1 ] ; then
    for 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}” 
      fi
    done
    fi
    /bin/rm -f $TMPFILE
    }
     
    get_deviceid
    Warning=false
    Critical=false
    for Devid in $Deviceidlist
    do
            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}”
            fi
    done
    if $Critical ; then
            echo “Critical-SSD_Life${resString}”
    elif $Warning  ; then
            echo “Warning-SSD_Life${resString}”
    else
            echo “OK”
    fi
    exit 0
    

      

  • 相关阅读:
    机器学习中 margin loss 、hinge loss 和 ramp loss 的区别
    ML 论文中 用到的 temperature
    对一系列 pickle load 进行解包,只保留最后几个
    Linux 常用命令速览
    Numpy 的 dtype 和 astype 的区别
    远程配置 tensorflow 环境
    pytorch 的一些坑
    Conda 配置虚拟 pytorch 环境 和 Tensorflow 环境
    Ubuntu 远程离线配置 pytorch 运行环境
    3.Vue起步
  • 原文地址:https://www.cnblogs.com/ylqmf/p/2703721.html
Copyright © 2011-2022 走看看