mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-20 12:24:25 +02:00
Very minor bugfixes (Rev 1.3)
This commit is contained in:
parent
0c7a0ed4fe
commit
6c8f7630ba
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# $Id: megaclisas-status,v 1.2 2011/07/26 16:52:51 root Exp $
|
# $Id: megaclisas-status,v 1.3 2012/01/27 11:59:08 root Exp $
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -41,7 +41,7 @@ def returnControllerModel(output):
|
|||||||
def returnArrayNumber(output):
|
def returnArrayNumber(output):
|
||||||
i = 0
|
i = 0
|
||||||
for line in output:
|
for line in output:
|
||||||
if re.match(r'^Virtual Disk.*$',line.strip()):
|
if re.match(r'^Virtual Drive:.*$',line.strip()):
|
||||||
i += 1
|
i += 1
|
||||||
return i
|
return i
|
||||||
|
|
||||||
@ -49,10 +49,14 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
id = 'c'+str(controllerid)+'u'+str(arrayid)
|
id = 'c'+str(controllerid)+'u'+str(arrayid)
|
||||||
operationlinennumber = False
|
operationlinennumber = False
|
||||||
linenumber = 0
|
linenumber = 0
|
||||||
|
type = ''
|
||||||
|
size = ''
|
||||||
|
state = ''
|
||||||
for line in output:
|
for line in output:
|
||||||
if re.match(r'^RAID Level:.*$',line.strip()):
|
if re.match(r'^RAID Level.*?:.*$',line.strip()):
|
||||||
type = 'RAID'+line.strip().split(':')[1].split(',')[0].split('-')[1].strip()
|
# type = 'RAID'+line.strip().split(':')[1].split(',')[0].split('-')[1].strip()
|
||||||
if re.match(r'^Size:.*$',line.strip()):
|
type = 'RAID'+line.strip().split(':')[1]
|
||||||
|
if re.match(r'^Size.*?:.*$',line.strip()):
|
||||||
# Size reported in MB
|
# Size reported in MB
|
||||||
if re.match(r'^.*MB$',line.strip().split(':')[1]):
|
if re.match(r'^.*MB$',line.strip().split(':')[1]):
|
||||||
size = line.strip().split(':')[1].strip('MB').strip()
|
size = line.strip().split(':')[1].strip('MB').strip()
|
||||||
@ -65,9 +69,9 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
else:
|
else:
|
||||||
size = line.strip().split(':')[1].strip('GB').strip()
|
size = line.strip().split(':')[1].strip('GB').strip()
|
||||||
size = str(int(round((float(size)))))+'G'
|
size = str(int(round((float(size)))))+'G'
|
||||||
if re.match(r'^State:.*$',line.strip()):
|
if re.match(r'^State.*?:.*$',line.strip()):
|
||||||
state = line.strip().split(':')[1].strip()
|
state = line.strip().split(':')[1].strip()
|
||||||
if re.match(r'^Ongoing Progresses:.*$',line.strip()):
|
if re.match(r'^Ongoing Progresses.*?:.*$',line.strip()):
|
||||||
operationlinennumber = linenumber
|
operationlinennumber = linenumber
|
||||||
linenumber += 1
|
linenumber += 1
|
||||||
if operationlinennumber:
|
if operationlinennumber:
|
||||||
@ -86,19 +90,20 @@ def returnDiskInfo(output,controllerid):
|
|||||||
for line in output:
|
for line in output:
|
||||||
if re.match(r'^Virtual Drive: [0-9]+.*$',line.strip()):
|
if re.match(r'^Virtual Drive: [0-9]+.*$',line.strip()):
|
||||||
arrayid = line.split('(')[0].split(':')[1].strip()
|
arrayid = line.split('(')[0].split(':')[1].strip()
|
||||||
|
if re.match(r'PD: [0-9]+ Information.*$',line.strip()):
|
||||||
|
olddiskid = diskid
|
||||||
|
diskid = line.split()[1].strip()
|
||||||
|
if olddiskid != False:
|
||||||
|
state = 'Offline'
|
||||||
|
model = 'Unknown'
|
||||||
if re.match(r'Firmware state: .*$',line.strip()):
|
if re.match(r'Firmware state: .*$',line.strip()):
|
||||||
state = line.split(':')[1].strip()
|
state = line.split(':')[1].strip()
|
||||||
if re.match(r'Inquiry Data: .*$',line.strip()):
|
if re.match(r'Inquiry Data: .*$',line.strip()):
|
||||||
model = line.split(':')[1].strip()
|
model = line.split(':')[1].strip()
|
||||||
model = re.sub(' +', ' ', model)
|
model = re.sub(' +', ' ', model)
|
||||||
if re.match(r'PD: [0-9]+ Information.*$',line.strip()):
|
if model != 'Unknown':
|
||||||
olddiskid = diskid
|
#### print str(arrayid)+' '+str(diskid)+' '+str(olddiskid)
|
||||||
diskid = line.split()[1].strip()
|
table.append([str(arrayid), str(diskid), state, model])
|
||||||
if olddiskid != False:
|
|
||||||
table.append([str(arrayid), str(olddiskid), state, model])
|
|
||||||
state = 'Offline'
|
|
||||||
model = 'Unknown'
|
|
||||||
table.append([str(arrayid), str(diskid), state, model])
|
|
||||||
return table
|
return table
|
||||||
|
|
||||||
cmd = 'megacli -adpCount -NoLog'
|
cmd = 'megacli -adpCount -NoLog'
|
||||||
@ -109,7 +114,7 @@ bad = False
|
|||||||
|
|
||||||
# List available controller
|
# List available controller
|
||||||
if printcontroller:
|
if printcontroller:
|
||||||
print '-- Controller informations --'
|
print '-- Controller information --'
|
||||||
print '-- ID | Model'
|
print '-- ID | Model'
|
||||||
controllerid = 0
|
controllerid = 0
|
||||||
while controllerid < controllernumber:
|
while controllerid < controllernumber:
|
||||||
@ -150,13 +155,12 @@ while controllerid < controllernumber:
|
|||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arraynumber = returnArrayNumber(output)
|
arraynumber = returnArrayNumber(output)
|
||||||
#### BUG: -LdPdInfo shows all PD on the adapter, not just for said LD..
|
#### BUG: -LdPdInfo shows all PD on the adapter, not just for said LD..
|
||||||
while arrayid <= arraynumber:
|
#### while arrayid <= arraynumber:
|
||||||
cmd = 'megacli -LdPdInfo -a'+str(controllerid)+' -NoLog'
|
cmd = 'megacli -LdPdInfo -a'+str(controllerid)+' -NoLog'
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arraydisk = returnDiskInfo(output,controllerid)
|
arraydisk = returnDiskInfo(output,controllerid)
|
||||||
for array in arraydisk:
|
for array in arraydisk:
|
||||||
print 'c'+str(controllerid)+'u'+array[0]+'p'+array[1]+' | '+array[3]+' | '+array[2]
|
print 'c'+str(controllerid)+'u'+array[0]+'p'+array[1]+' | '+array[3]+' | '+array[2]
|
||||||
arrayid += 1
|
|
||||||
controllerid += 1
|
controllerid += 1
|
||||||
|
|
||||||
if bad:
|
if bad:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user