自动检查RAID 信息的一个脚本

1. #!/bin/sh

2. Hostname=`/bin/hostname`

3. Hostip=`awk-F= ‘/IPADDR/ {print $2}’ /etc/sysconfig/network-scripts/ifcfg-eth0`

4.  

5. Battery=`/opt/MegaCli-AdpBbuCmd -GetBbuStatus -aALL|grep “Charger Status”|awk -F: ‘{print $1″:”$2}’`

6. raid=`/opt/MegaCli-cfgdsply -aALL|grep “RAID Level”|tail -1|awk -F: ‘{print $1″ :”$2}’`

7. Disknum=`/opt/MegaCli-cfgdsply -aALL|grep -c “Non Coerced Size”`

8. Onlinedisk=`/opt/MegaCli-cfgdsply -aALL | grep “Online” | wc -l | sed ‘s/ //’`

9. Faileddisk=`/opt/MegaCli-AdpAllInfo -aALL | grep “Failed Disks”|awk -F’ ‘ ‘{print $4}’`

10. 

11.echo“####################### Host Information #########################”

12.echo“HostName : $Hostname”

13.echo“HostIp : $Hostip”

14.echo“”

15.echo“####################### Raid Information ########################”

16.#echo“$Raidmode”

17.case“$raid”

18.in

19.“RAIDLevel : Primary-1, Secondary-0, RAID Level Qualifier-0″) echo “Raid Level :Raid1″;;

20.“RAIDLevel : Primary-0, Secondary-0, RAID Level Qualifier-0″) echo “Raid Level :Raid0″;;

21.“RAIDLevel : Primary-5, Secondary-0, RAID Level Qualifier-3″) echo “Raid Level :Raid5″;;

22.“RAIDLevel : Primary-1, Secondary-3, RAID Level Qualifier-0″) echo “Raid Level :Raid10″;;

23.esac

24. 

25.if [-z "$Battery" ];then

26.echo“Battery :Null”

27.else

28.echo“$Battery”

29.fi

30. 

31.echo“Total Diak Number:$Disknum”

32.echo“Online Disk Number:$Onlinedisk”

33.echo“Failed Disk Number:$Faileddisk”

34.echo“”

 

你可能感兴趣的:(raid,脚本)