@tony-yin
2017-12-26T16:33:06.000000Z
字数 3890
阅读 713
Disk
Megacli
process file: mcs3-deploy/src/mcs3/raidcardutil.py
class RaidCardToolFactory() // process raid card type to determine which tool
class MegaraidTool() // Megaraid type card
class HBATool() // HBA type card
RaidCardToolFactory
类实现了工厂模式,在这个类中通过raid
卡信息然后判断实例化具体的工具类;
判断的方式是把目前系统存在的raid
卡型号和对应工具制定一个map
,然后对应调用;
同一个API
对应不同工具都有具体的实现方式;
最后针对不同工具的返回结果集进行统一的处理,这边也需要对不同工具和对应属性key
进行一个map
构建
对外暴露只有一个API
,以get_disk_type
为例,调用方式如下:
from mcs3.raidcardutils import RaidCardToolFactory // refer module
tool = RaidCardToolFactory().getTool() // init class
disks = tool.get_disk_type('sda') // invoke function
// return 'HDD' or 'SSD'
path: /mcs3-disk-mon/usr/local/bin/
Desc: 检查raid
盘的状态
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL -NoLog | grep State
/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -AdpAllInfo -aALL -NoLog | grep Degraded
/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -AdpAllInfo -aALL -NoLog | grep Offline
/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -AdpAllInfo -aALL -NoLog | grep "Critical Disks"
/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -AdpAllInfo -aALL -NoLog | grep "Failed Disks"
/opt/MegaRAID/MegaCli/MegaCli64 pdlist aAll -NoLog | awk -f /usr/local/bin/summary.awk
line 159, line 168
Desc: 判断megacli
是否安装
Usage:
os.path.exists(MEGACLI_BIN)
path: /mcs3-deploy/src/mcs3/
Desc: 清除Megacli
控制器缓存
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 -AdpCacheFlush -Aall -NoLog
path: /mcs3-deploy/src/mcs3/
Desc: 获取raid
虚拟驱动器的信息
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 -LDPDinfo -Aall |grep -Ei "MediaType|Virtual Drive"
Desc: 加固一下raid
相关配置(覆盖配置),例如电池、写入模式(WT,WB etc
)、cache
等等
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCMD -Aall |grep Exit | tr -d "\n"
/opt/MegaRAID/MegaCli/MegaCli64 LDSetProp WT -L{} -Aall
/opt/MegaRAID/MegaCli/MegaCli64 LDSetProp -NoCachedBadBBU -L{} -Aall
/opt/MegaRAID/MegaCli/MegaCli64 LDSetProp WT -L{} -Aall
/opt/MegaRAID/MegaCli/MegaCli64 LDSetProp DisDskCache -L{} -Aall
/opt/MegaRAID/MegaCli/MegaCli64 LDSetProp ADRA -L{} -Aall
/opt/MegaRAID/MegaCli/MegaCli64 LDSetProp DIRECT -L{} -Aall
path: /mcs3-deploy/src/mcs3/
Desc: 获取本地所有磁盘信息
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 pdlist aAll -NoLog | awk -f /usr/local/bin/summary.awk
Desc: 获取所有物理磁盘部分信息(槽号和模式)
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL -NoLog | grep "Slot Number"
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL -NoLog | grep "Firmware state"
Desc: 获取所有物理磁盘部分信息(槽号和序列号)
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 pdlist aAll -NoLog | awk -f /usr/local/bin/summary.awk
path: /mcs3-deploy/bin/cluster_check/
Desc: 获取raid
信息
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 -LDPDinfo -Aall |grep -Ei "Media Type|Virtual Drive"
/opt/MegaRAID/MegaCli/MegaCli64 -LDinfo -L {} -Aall|grep -Ei 'Current Cache Policy|Disk Cache Policy
Desc: 查看raid
卡信息
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -A0 -NoLog |grep -Ei 'Critical Disks|Failed Disks'
/opt/MegaRAID/MegaCli/MegaCli64 -LDPDinfo -Aall -NoLog|grep -Ei 'Virtual Drive|^State|Enclosure Device|Slot Number|Media Error Count|Other Error Count|Firmware state|flagged a S.M.A.R.T alert'
Desc: 获取SSD
信息
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 -LDPDinfo -A0| grep -Ei "Virtual Drive|Enclosure Device|Slot Number|Device Id|Inquiry Data|Media Type"
path: /mcs3-deploy/bin/
Desc: 获取物理磁盘信息
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 PDList -A0 | grep -Ei 'Enclosure Device|Slot Number|Media Type|Firmware state'
Desc: 获取raid
卡相关信息
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 CfgDsply -A0 |grep -Ei'Disk Group|Enclosure Device|Slot Number'
Desc: 删除全局热备
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 PDHSP -Rmv -PhysDrv [{}:{}] -A0
Desc: 在线做raid
Usage:
/opt/MegaRAID/MegaCli/MegaCli64 CfgLdAdd -r{}
Desc: 指定盘做全局热备
/opt/MegaRAID/MegaCli/MegaCli64 PDHSP -Set PhysDrv