700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 检测raid类型和磁盘坏道脚本

检测raid类型和磁盘坏道脚本

时间:2019-05-04 18:32:47

相关推荐

检测raid类型和磁盘坏道脚本

#!/bin/sh#脚本功能:#安装工具MegaCli64#Host Information:主机名和ip地址#Raid Information:raid信息和充电状态#WARNING Information:MediaErrcount检测坏块和哪块盘#Disk Information:磁盘信息#上传MegaCli压缩包到opt目录下Megdir=/opt/MegaRAID/MegaCli/cd /optif [ ! -d $Megdir ];thenunzip MegaCLI.zip cd 8.07.10_MegaCLI_Linux/Linux\ MegaCLI\ 8.07.10/rpm -ivh MegaCli-8.07.10-1.noarch.rpmcp /opt/MegaRAID/MegaCli/MegaCli* /usr/local/sbincp /opt/MegaRAID/MegaCli/MegaCli* /usr/sbinecho "MegaCLI install sucess"elseecho "MegaCLI already install"Hostname=`/bin/hostname`Hostip=`ifconfig | grep broadcast | awk "NR==1" | awk -F" " '{print $2}'`Battery=`MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL|grep "Charger Status"|awk -F: '{print $1" :"$2}'`raid=`MegaCli64 -cfgdsply -aALL|grep "RAID Level"|tail -1|awk -F: '{print $1" :"$2}'`Disknum=`MegaCli64 -cfgdsply -aALL|grep -c "Non Coerced Size"`Onlinedisk=`MegaCli64 -cfgdsply -aALL | grep "Online" | wc -l | sed 's/ //'`Faileddisk=`MegaCli64 -AdpAllInfo -aALL | grep "Failed Disks"|awk -F' ' '{print $4}'`echo ""echo "####################### Host Information #########################"echo "HostName: $Hostname"echo "HostIp : $Hostip"echo ""#raid信息echo "####################### Raid Information ########################"case "$raid"in"RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0") echo "Raid Level :Raid 1";;"RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0") echo "Raid Level :Raid 0";;"RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3") echo "Raid Level :Raid 5";;"RAID Level : Primary-1, Secondary-3, RAID Level Qualifier-0") echo "Raid Level :Raid 10";;esac#充电状态if [ -z "$Battery" ];thenecho "Battery :Null"elseecho "$Battery"fiecho ""echo "####################### WARNING Information ########################"#预警的盘以及位置CriticalDisk=`/usr/sbin/MegaCli64 -AdpAllInfo -aALL | grep "Critical Disks" | awk '{print $4}'`if [ $CriticalDisk -eq 0 ];thenecho "Critical Disks is:0"elseCriDisk=`/usr/sbin/MegaCli64 -AdpAllInfo -aALL| grep -E 'Predictive|Slot' | awk '{if(NR%3){printf$0":"}else{print $0}}'|awk -F':' '{if($4!=0){print $2+1}}'`echo "WARNING Critical Disks In:$CriticalDisk"echo "Sector In:$CriDisk"fi#MediaErrcount检测坏块和哪块盘MediaErrcount=`/usr/sbin/MegaCli64 -pdlist -aALL | grep -E "Media Error" |awk -F’:’ -v errcount=0 '{errcount+=$2}END{print errcount}'`OtherErrcount=`/usr/sbin/MegaCli64 -pdlist -aALL | grep -E "Other Error" |awk -F’:’ -v errcount=0 '{errcount+=$2}END{print errcount}'`#坏盘的位置if [[ $MediaErrcount==0||$OtherErrcount==0 ]];thenmDoD=`/usr/sbin/MegaCli64 -pdlist -aALL |grep -E "Media Error|Other Error|Slot" | awk '{if(NR%3){printf$0":"}else{print $0}}' | awk -F':' '{if($4!=0||$6!=0){print $2+1}}'`echo -e "Bad Block In:$mDoD"echo -e "CRITICAL:$MediaErrcount"elseecho "mediaerr:0 and othererr:0"fiecho ""echo "####################### Disk Information ########################"echo "Total Disk Number:$Disknum"echo "Online Disk Number:$Onlinedisk"echo "Failed Disk Number:$Faileddisk"echo ""fi

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。
相关阅读
磁盘坏道检测

磁盘坏道检测

2021-06-28

8.磁盘坏道检测

8.磁盘坏道检测

2020-02-11

检测磁盘坏道修复

检测磁盘坏道修复

2020-08-09

磁盘坏道的检测及修复

磁盘坏道的检测及修复

2022-12-22