【Shell】查看系统raid卡信息


点击(此处)折叠或打开

  1. print_usage()
  2. {
  3.  echo
  4.  echo \" Usage: tbraid cmd [argments]\"
  5.  echo \"---------------------------------------------------------------------------\"
  6.  echo \" cmd argments description\"
  7.  echo \" ======== ====================== ===========================================\"
  8.  echo \" info : Show all info about raid card\"
  9.  echo \" log : Show log of raid card\"
  10.  echo \" raid : Show raid info\"
  11.  echo \" disk : Show all physical disks connect to raid card\"
  12.  echo \" cache : Show cache policy of raid card\"
  13.  echo \" diskcache : Show physical disk cache policy\"
  14.  echo \" bbu : Show bbu info\"
  15.  echo \" rate : Show rebuild rate, default is 30%\"
  16.  echo \" setrate [rate] : Set rebuild rate, be careful\"
  17.  echo \" setcache [policy] : Set cache policy,maybe WT|WB|RA|NORA|ADRA|Cached|Direct|CachedBadBBUi|NoCachedBadBBU\"
  18.  echo \" setdiskcache [enable|disable] : Enable or disable physical disk cache \"
  19.  echo \" help : Print this help info\"
  20.  echo \"==========================================================================\"
  21.     echo \"support for HP&LSI Raid-Card\"
  22. }


  23. hptag=`/sbin/lspci |grep -i raid|grep -i Hewlett|wc -l`
  24. lsitag=`/sbin/lspci |grep -i raid|grep -i Mega|wc -l`
  25. if [ $lsitag -gt 0 ];then
  26.     megacli=\"/opt/MegaRAID/MegaCli/MegaCli64\"
  27.     if [ ! -f $megacli ];then
  28.        echo \"you need to install MegaCli first. run sudo yum install MegaCli\"
  29.        exit
  30.     fi
  31. elif [ $hptag -gt 0 ];then
  32.     hpacucli=\"/usr/local/bin/hpacucli\"
  33.     if [ ! -f $hpacucli ];then
  34.         hpacucli=\"/usr/sbin/hpacucli\"
  35.         if [ ! -f $hpacucli ];then
  36.             echo \"you need to install hpacucli first. run sudo yum install hpacucli\"
  37.             exit
  38.         fi
  39.     fi
  40. else
  41.     echo \"The Raid-Card could not be identified\"
  42.     exit
  43. fi

  44. CMD=`echo $1 | tr [A-Z] [a-z]`
  45. if [ -z $CMD ];then
  46.   /sbin/lspci | grep RAID
  47. fi
  48. if [ $lsitag -gt 0 ];then
  49.   case $CMD in
  50.   info)
  51.   sudo $megacli -AdpAllInfo -aALL
  52.   ;;
  53.   log)
  54.   sudo $megacli -FwTermLog -Dsply -aALL
  55.   ;;
  56.   raid)
  57.   sudo $megacli -LDInfo -Lall -aALL
  58.   ;;
  59.   disk)
  60.   sudo $megacli -PDList -aALL
  61.   ;;
  62.   cache)
  63.   sudo $megacli -LDGetProp -Cache -LALL -aALL
  64.   ;;
  65.   diskcache)
  66.   sudo $megacli -LDGetProp -DskCache -LALL -aALL
  67.   ;;
  68.   bbu)
  69.   sudo $megacli -AdpBbuCmd -aALL
  70.   ;;
  71.   rate)
  72.   sudo $megacli -AdpGetProp RebuildRate -aAll
  73.   ;;
  74.   setrate)
  75.   sudo $megacli -AdpSetProp RebuildRate $2 -aALL
  76.   ;;
  77.   setcache)
  78.   sudo $megacli -LDSetProp $2 -Lall -aALL
  79.   ;;
  80.   setdiskcache)
  81.   if [ $2 == \"enable\" ];then
  82.     sudo $megacli -LDSetProp EnDskCache -LAll -aAll
  83.   elif [ $2 == \"disable\" ];then
  84.     sudo $megacli -LDSetProp DisDskCache -LAll -aAll
  85.   fi
  86.   ;;
  87.   *)
  88.   print_usage
  89.   ;;
  90.   esac

  91. elif [ $hptag -gt 0 ];then
  92.   tmpslot=`sudo hpacucli ctrl all show status | grep \'Smart Array\'|awk \'{ print $6 }\'`

  93.   case $CMD in
  94.   info)
  95.   sudo $hpacucli controller slot=$tmpslot show
  96.   ;;
  97.   log)
  98.   sudo $hpacucli ctrl all diag file=/tmp/diag.zip
  99.   sudo unzip /tmp/diag.log -d /tmp
  100.   sudo less /tmp/ADUReport.txt
  101.   ;;
  102.   raid)
  103.   sudo $hpacucli controller slot=$tmpslot logicaldrive all show
  104.   ;;
  105.   disk)
  106.   sudo $hpacucli controller slot=$tmpslot physicaldrive all show
  107.   ;;
  108.   cache)
  109.   sudo $hpacucli controller slot=$tmpslot show
  110.   ;;
  111.   diskcache)
  112.   sudo $hpacucli controller slot=$tmpslot show
  113.   ;;
  114.   bbu)
  115.   sudo $hpacucli controller slot=$tmpslot show
  116.   ;;
  117.   rate)
  118.   echo \"hp raid no this function\"
  119.   ;;
  120.   setrate)
  121.   echo \"hp raid no this function\"
  122.   ;;
  123.   setcache)
  124.   echo \"hp raid no this function\"
  125.   ;;
  126.   setdiskcache)
  127.   if [ $2 == \"enable\" ];then
  128.     echo \"hp raid no this function\"
  129.   elif [ $2 == \"disable\" ];then
  130.     echo \"hp raid no this function\"
  131.   fi
  132.   ;;
  133.   *)
  134.   print_usage
  135.   ;;
  136.   esac
  137. fi

请使用浏览器的分享功能分享到微信等