我的博客已迁移到xdoujiang.com请去那边和我交流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}megacliactionexit 02、查看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";;esacecho "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"}diskstatusexit 0执行结果:===============Raid Information===============Raid Level:5Total Diak Number:7Online Disk Number:7Failed Disk Number:0Critical Disk Number:0===============Current Status=================Firmware state: OnlineFirmware state: OnlineFirmware state: OnlineFirmware state: OnlineFirmware state: OnlineFirmware state: OnlineFirmware state: OnlineFirmware state: Hotspare