mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-23 13:54:23 +02:00
Adding support for non-configured drives. fixed a few bugs.. (Rev 1.11)
This commit is contained in:
parent
312e58a97a
commit
4ec7f462d4
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
# $Id: megaclisas-status,v 1.10 2015/01/14 18:12:22 root Exp $
|
||||
# $Id: megaclisas-status,v 1.11 2015/01/14 19:24:10 root Exp $
|
||||
|
||||
import os
|
||||
import re
|
||||
@ -93,7 +93,7 @@ def returnArrayInfo(output,controllerid,arrayid):
|
||||
def returnDiskInfo(output,controllerid):
|
||||
arrayid = False
|
||||
diskid = False
|
||||
olddiskid = False
|
||||
oldenclid = False
|
||||
enclid = False
|
||||
slotid = False
|
||||
lsidid = 'Unknown'
|
||||
@ -103,16 +103,21 @@ def returnDiskInfo(output,controllerid):
|
||||
speed = 'Unknown'
|
||||
temp = 'Unk0C'
|
||||
for line in output:
|
||||
if re.match(r'Enclosure Device ID: .*$',line.strip()):
|
||||
# We match here early in the analysis so reset the vars if this is a new disk we're reading..
|
||||
oldenclid = enclid
|
||||
enclid = line.split(':')[1].strip()
|
||||
if oldenclid != False:
|
||||
state = 'Offline'
|
||||
model = 'Unknown'
|
||||
speed = 'Unknown'
|
||||
temp = 'Unk0C'
|
||||
slotid = False
|
||||
lsidid = 'Unknown'
|
||||
if re.match(r'^Virtual Drive: [0-9]+.*$',line.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'Enclosure Device ID: .*$',line.strip()):
|
||||
enclid = line.split(':')[1].strip()
|
||||
if re.match(r'^Device Id: .*$',line.strip()):
|
||||
lsidid = line.split(':')[1].strip()
|
||||
if re.match(r'Slot Number: .*$',line.strip()):
|
||||
@ -125,6 +130,7 @@ def returnDiskInfo(output,controllerid):
|
||||
if re.match(r'Device Speed: .*$',line.strip()):
|
||||
speed = line.split(':')[1].strip()
|
||||
if re.match(r'Drive Temperature :.*$',line.strip()):
|
||||
# Drive temp is amongst the last few lines matched, decide here if we add information to the table..
|
||||
temp = line.split(':')[1].strip()
|
||||
temp = re.sub('\(.*\)', '', temp)
|
||||
if model != 'Unknown':
|
||||
@ -132,6 +138,57 @@ def returnDiskInfo(output,controllerid):
|
||||
table.append([str(arrayid), str(diskid), state, model, speed, temp, enclid, slotid, lsidid])
|
||||
return table
|
||||
|
||||
|
||||
def returnUnconfDiskInfo(output,controllerid):
|
||||
arrayid = False
|
||||
diskid = False
|
||||
olddiskid = False
|
||||
enclid = False
|
||||
slotid = False
|
||||
lsidid = 'Unknown'
|
||||
table = []
|
||||
state = 'Offline'
|
||||
model = 'Unknown'
|
||||
speed = 'Unknown'
|
||||
temp = 'Unk0C'
|
||||
for line in output:
|
||||
if re.match(r'Enclosure Device ID: .*$',line.strip()):
|
||||
# We match here early in the analysis so reset the vars if this is a new disk we're reading..
|
||||
oldenclid = enclid
|
||||
enclid = line.split(':')[1].strip()
|
||||
if oldenclid != False:
|
||||
arrayid = False
|
||||
state = 'Offline'
|
||||
model = 'Unknown'
|
||||
speed = 'Unknown'
|
||||
temp = 'Unk0C'
|
||||
slotid = False
|
||||
lsidid = 'Unknown'
|
||||
|
||||
if re.match(r'^Drive.s position: DiskGroup: [0-9]+,.*$',line.strip()):
|
||||
arrayid = line.split(',')[1].split(':')[1].strip()
|
||||
if re.match(r'^Device Id: [0-9]+.*$',line.strip()):
|
||||
diskid = line.split(':')[1].strip()
|
||||
if re.match(r'^Device Id: .*$',line.strip()):
|
||||
lsidid = line.split(':')[1].strip()
|
||||
if re.match(r'Slot Number: .*$',line.strip()):
|
||||
slotid = line.split(':')[1].strip()
|
||||
if re.match(r'Firmware state: .*$',line.strip()):
|
||||
state = line.split(':')[1].strip()
|
||||
if re.match(r'Inquiry Data: .*$',line.strip()):
|
||||
model = line.split(':')[1].strip()
|
||||
model = re.sub(' +', ' ', model)
|
||||
if re.match(r'Device Speed: .*$',line.strip()):
|
||||
speed = line.split(':')[1].strip()
|
||||
if re.match(r'Drive Temperature :.*$',line.strip()):
|
||||
# Drive temp is amongst the last few lines matched, decide here if we add information to the table..
|
||||
temp = line.split(':')[1].strip()
|
||||
temp = re.sub('\(.*\)', '', temp)
|
||||
if arrayid == False:
|
||||
### print str(arrayid)+' '+str(diskid)+' '+str(olddiskid)
|
||||
table.append([state, model, speed, temp, enclid, slotid, lsidid])
|
||||
return table
|
||||
|
||||
cmd = 'megacli -adpCount -NoLog'
|
||||
output = getOutput(cmd)
|
||||
controllernumber = returnControllerNumber(output)
|
||||
@ -191,6 +248,27 @@ while controllerid < controllernumber:
|
||||
print 'c'+str(controllerid)+'u'+array[0]+'p'+array[1]+'\t| '+array[3]+' | '+array[2]+' | '+array[4]+' | '+array[5]+' | ID: \'['+array[6]+':'+array[7]+']\' | '+array[8]
|
||||
controllerid += 1
|
||||
|
||||
|
||||
print ''
|
||||
print '-- Unconfigured Disks information --'
|
||||
print '-- ID\t| Model | Status | Speed | Temperature | Slot ID | LSI Device ID '
|
||||
|
||||
controllerid = 0
|
||||
while controllerid < controllernumber:
|
||||
arrayid = 0
|
||||
cmd = 'megacli -LDInfo -lall -a'+str(controllerid)+' -NoLog'
|
||||
output = getOutput(cmd)
|
||||
arraynumber = returnArrayNumber(output)
|
||||
#### BUG: -LdPdInfo shows all PD on the adapter, not just for said LD..
|
||||
#### while arrayid <= arraynumber:
|
||||
cmd = 'megacli -PDList -a'+str(controllerid)+' -NoLog'
|
||||
output = getOutput(cmd)
|
||||
arraydisk = returnUnconfDiskInfo(output,controllerid)
|
||||
for array in arraydisk:
|
||||
print 'c'+str(controllerid)+'\t| '+array[1]+' | '+array[0]+' | '+array[2]+' | '+array[3]+' | ID: \'['+array[4]+':'+array[5]+']\' | '+array[6]
|
||||
controllerid += 1
|
||||
|
||||
|
||||
if bad:
|
||||
print '\nThere is at least one disk/array in a NOT OPTIMAL state.'
|
||||
sys.exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user