1、cat megacli.sh #!/bin/bash #-------------------------------------------------- #Created:2015-05-22 #Author:jimmygong #Mail:jimmygong@taomee.com #Function: #Version:1.0 #-------------------------------------------------- function megacliaction () { megacmd="/usr/local/sbin/MegaCli64" if [[ -e $megacmd ]] then critical=$(sudo $megacmd -AdpAllInfo -aALL -NoLog|awk ‘/Critical Disks/ {print $4}‘) failed=$(sudo $megacmd -AdpAllInfo -aALL -NoLog|awk ‘/Failed Disks/ {print $4}‘) [[ -z $critical ]] || [[ -z $failed ]] && echo "Storage Capture Failure" && exit 0 [[ $critical -ne 0 ]] || [[ $failed -ne 0 ]] && echo "Storage Disk Failure" && exit 0 echo "Storage Disk Normal" else echo "MegaCli64 Problem" exit 1 fi } megacliaction exit 0 2、查看raid信息 cat megacli2.sh #!/bin/bash #-------------------------------------------------- #Created:2015-05-22 #Author:jimmygong #Mail:jimmygong@taomee.com #Function: #Version:1.0 #-------------------------------------------------- function diskstatus () { echo -e "===============Raid Information===============" cmd="/usr/local/sbin/MegaCli64" raid=`$cmd -cfgdsply -aALL|grep "RAID Level"|tail -1|awk -F: ‘{print $1" :"$2}‘` disknum=`$cmd -cfgdsply -aALL|grep "Number Of Drives"|awk -F: ‘{print $2}‘` onlinedisk=`$cmd -cfgdsply -aALL|grep -c "Online"` faileddisk=`$cmd -AdpAllInfo -aALL -NoLog|awk ‘/Failed Disks/ {print $4}‘` criticaldisk=`$cmd -AdpAllInfo -aALL -NoLog|awk ‘/Critical Disks/ {print $4}‘` case "$raid" in "RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0") echo "Raid Level:1";; "RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0") echo "Raid Level:0";; "RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3") echo "Raid Level:5";; "RAID Level : Primary-6, Secondary-0, RAID Level Qualifier-3") echo "Raid Level:6";; "RAID Level : Primary-1, Secondary-3, RAID Level Qualifier-0") echo "Raid Level:10";; esac echo "Total Diak Number:$disknum" echo "Online Disk Number:$onlinedisk" echo "Failed Disk Number:$faileddisk" echo "Critical Disk Number:$criticaldisk" echo -e "===============Current Status=================" $cmd -PDList -aALL|grep "Firmware state" } diskstatus exit 0
本文出自 “7928217” 博客,请务必保留此出处http://7938217.blog.51cto.com/7928217/1653705
原文地址:http://7938217.blog.51cto.com/7928217/1653705