mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-24 22:34:21 +02:00
Merge pull request #28 from ElCoyote27/master
[hwraid] Improve display of Nested spans in >= 10 RAID levels
This commit is contained in:
commit
4613617950
@ -29,6 +29,7 @@ totalunconfdrivenumber = 0
|
|||||||
|
|
||||||
# Hardcode a max of 16 HBA for now. LDTable must be initialized to accept populating list of LD's into each ctlr's list.
|
# Hardcode a max of 16 HBA for now. LDTable must be initialized to accept populating list of LD's into each ctlr's list.
|
||||||
LDTable = [ [] * 16 for i in range(16) ]
|
LDTable = [ [] * 16 for i in range(16) ]
|
||||||
|
NestedLDTable = [ [] * 16 for i in range(16) ]
|
||||||
# Outputs is a 'dict' of all MegaCLI outputs so we can re-use them during loops..
|
# Outputs is a 'dict' of all MegaCLI outputs so we can re-use them during loops..
|
||||||
Outputs = {}
|
Outputs = {}
|
||||||
|
|
||||||
@ -138,12 +139,24 @@ def returnTotalDriveNumber(output):
|
|||||||
if re.match(r'Number of Physical Drives on Adapter.*$',line.strip()):
|
if re.match(r'Number of Physical Drives on Adapter.*$',line.strip()):
|
||||||
return int(line.split(':')[1].strip())
|
return int(line.split(':')[1].strip())
|
||||||
|
|
||||||
|
def returnRebuildProgress(output):
|
||||||
|
percent = 0
|
||||||
|
tmpstr = ''
|
||||||
|
for line in output:
|
||||||
|
if re.match(r'^Rebuild Progress on Device at Enclosure.*, Slot .* Completed ',line.strip()):
|
||||||
|
tmpstr = line.split('Completed')[1].strip()
|
||||||
|
percent = int(tmpstr.split('%')[0].strip())
|
||||||
|
return percent
|
||||||
|
|
||||||
def returnUnconfDriveNumber(output):
|
def returnUnconfDriveNumber(output):
|
||||||
confdrives = 0
|
confdrives = 0
|
||||||
unconfdrives = 0
|
unconfdrives = 0
|
||||||
|
totaldrivenumber = 0
|
||||||
for line in output:
|
for line in output:
|
||||||
if re.match(r'.*Number of PDs:.*$',line.strip()):
|
if re.match(r'.*Number of PDs:.*$',line.strip()):
|
||||||
confdrives += int(line.split(':')[2].strip())
|
totaldrivenumber += int(line.split(':')[2].strip())
|
||||||
|
if re.match(r'^Firmware state:.*$',line.strip()):
|
||||||
|
confdrives += 1
|
||||||
unconfdrives = totaldrivenumber - confdrives
|
unconfdrives = totaldrivenumber - confdrives
|
||||||
return int(unconfdrives)
|
return int(unconfdrives)
|
||||||
|
|
||||||
@ -289,7 +302,7 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
state = line.strip().split(':')[1].strip()
|
state = line.strip().split(':')[1].strip()
|
||||||
if re.match(r'^Strip Size.*?:.*$',line.strip()):
|
if re.match(r'^Strip Size.*?:.*$',line.strip()):
|
||||||
strpsz = line.strip().split(':')[1].strip()
|
strpsz = line.strip().split(':')[1].strip()
|
||||||
if re.match(r'^Number Of Drives.*:.*$',line.strip()):
|
if re.match(r'^Number Of Drives per span.*:.*$',line.strip()):
|
||||||
diskperspan = int(line.strip().split(':')[1].strip())
|
diskperspan = int(line.strip().split(':')[1].strip())
|
||||||
if re.match(r'^Current Cache Policy.*?:.*$',line.strip()):
|
if re.match(r'^Current Cache Policy.*?:.*$',line.strip()):
|
||||||
props = line.strip().split(':')[1].strip()
|
props = line.strip().split(':')[1].strip()
|
||||||
@ -321,10 +334,12 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
# Compute the RAID level
|
# Compute the RAID level
|
||||||
if (int(spandepth) >= 2):
|
if (int(spandepth) >= 2):
|
||||||
raidtype = str('RAID-' + str(raidlvl) + '0')
|
raidtype = str('RAID-' + str(raidlvl) + '0')
|
||||||
|
NestedLDTable[controllerid][arrayid] = True
|
||||||
else:
|
else:
|
||||||
if(raidlvl == 1):
|
if(raidlvl == 1):
|
||||||
if(diskperspan > 2):
|
if(diskperspan > 2):
|
||||||
raidtype = str('RAID-10')
|
raidtype = str('RAID-10')
|
||||||
|
NestedLDTable[controllerid][arrayid] = True
|
||||||
else:
|
else:
|
||||||
raidtype = str('RAID-' + str(raidlvl))
|
raidtype = str('RAID-' + str(raidlvl))
|
||||||
else:
|
else:
|
||||||
@ -338,18 +353,25 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
|
|
||||||
def returnDiskInfo(output,controllerid):
|
def returnDiskInfo(output,controllerid):
|
||||||
arrayid = False
|
arrayid = False
|
||||||
|
sarrayid = 'Unknown'
|
||||||
diskid = False
|
diskid = False
|
||||||
oldenclid = False
|
oldenclid = False
|
||||||
enclid = False
|
enclid = False
|
||||||
|
spanid = False
|
||||||
slotid = False
|
slotid = False
|
||||||
lsidid = 'Unknown'
|
lsidid = 'Unknown'
|
||||||
table = []
|
table = []
|
||||||
fstate = 'Offline'
|
fstate = 'Offline'
|
||||||
|
substate = 'Unknown'
|
||||||
model = 'Unknown'
|
model = 'Unknown'
|
||||||
speed = 'Unknown'
|
speed = 'Unknown'
|
||||||
dsize = 'Unknown'
|
dsize = 'Unknown'
|
||||||
temp = 'Unk0C'
|
temp = 'Unk0C'
|
||||||
|
percent = 0
|
||||||
for line in output:
|
for line in output:
|
||||||
|
if re.match(r'^Span: [0-9]+ - Number of PDs:',line.strip()):
|
||||||
|
spanid = line.split(':')[1].strip()
|
||||||
|
spanid = re.sub(' - Number of PDs.*', '', spanid)
|
||||||
if re.match(r'Enclosure Device ID: .*$',line.strip()):
|
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..
|
# We match here early in the analysis so reset the vars if this is a new disk we're reading..
|
||||||
oldenclid = enclid
|
oldenclid = enclid
|
||||||
@ -375,6 +397,7 @@ def returnDiskInfo(output,controllerid):
|
|||||||
slotid = line.split(':')[1].strip()
|
slotid = line.split(':')[1].strip()
|
||||||
if re.match(r'Firmware state: .*$',line.strip()):
|
if re.match(r'Firmware state: .*$',line.strip()):
|
||||||
fstate = line.split(':')[1].strip()
|
fstate = line.split(':')[1].strip()
|
||||||
|
subfstate = re.sub('\(.*', '', fstate)
|
||||||
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)
|
||||||
@ -399,8 +422,18 @@ def returnDiskInfo(output,controllerid):
|
|||||||
temp = line.split(':')[1].strip()
|
temp = line.split(':')[1].strip()
|
||||||
temp = re.sub(' \(.*\)', '', temp)
|
temp = re.sub(' \(.*\)', '', temp)
|
||||||
if model != 'Unknown':
|
if model != 'Unknown':
|
||||||
#### print str(arrayid)+' '+str(diskid)+' '+str(olddiskid)
|
dbgprint('Disk Info: '+str(arrayid)+' '+str(diskid)+' '+str(oldenclid))
|
||||||
table.append([str(arrayid), str(diskid), mtype, model, dsize, fstate , speed, temp, enclid, slotid, lsidid])
|
if subfstate == 'Rebuild':
|
||||||
|
cmd = '%s pdrbld -showprog -physdrv\[%s:%s\] -a%d -NoLog' % (megaclipath, enclid, slotid, controllerid)
|
||||||
|
output = getOutput(cmd)
|
||||||
|
percent = returnRebuildProgress(output)
|
||||||
|
fstate = str('Rebuilding (%d%%)' % (percent))
|
||||||
|
|
||||||
|
if (( NestedLDTable[controllerid][int(arrayid)] == True) and (spanid != False)):
|
||||||
|
sarrayid = str(arrayid)+"s"+spanid
|
||||||
|
else:
|
||||||
|
sarrayid = str(arrayid)
|
||||||
|
table.append([sarrayid, str(diskid), mtype, model, dsize, fstate , speed, temp, enclid, slotid, lsidid])
|
||||||
return table
|
return table
|
||||||
|
|
||||||
|
|
||||||
@ -413,6 +446,7 @@ def returnUnconfDiskInfo(output,controllerid):
|
|||||||
lsidid = 'Unknown'
|
lsidid = 'Unknown'
|
||||||
table = []
|
table = []
|
||||||
fstate = 'Offline'
|
fstate = 'Offline'
|
||||||
|
substate = 'Unknown'
|
||||||
model = 'Unknown'
|
model = 'Unknown'
|
||||||
speed = 'Unknown'
|
speed = 'Unknown'
|
||||||
mtype = 'Unknown'
|
mtype = 'Unknown'
|
||||||
@ -548,6 +582,7 @@ if printarray:
|
|||||||
ldid += 1
|
ldid += 1
|
||||||
if re.match(r'^Virtual Drive:',line.strip()):
|
if re.match(r'^Virtual Drive:',line.strip()):
|
||||||
LDTable[controllerid].append ( ldid )
|
LDTable[controllerid].append ( ldid )
|
||||||
|
NestedLDTable[controllerid].append ( False )
|
||||||
ldcount += 1
|
ldcount += 1
|
||||||
ldid += 1
|
ldid += 1
|
||||||
|
|
||||||
@ -629,6 +664,7 @@ if totaldrivenumber:
|
|||||||
print '-- Disk information --'
|
print '-- Disk information --'
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
dlen = 0
|
||||||
mlen = 0
|
mlen = 0
|
||||||
flen = 0
|
flen = 0
|
||||||
controllerid = 0
|
controllerid = 0
|
||||||
@ -644,12 +680,14 @@ if totaldrivenumber:
|
|||||||
arraydisk = returnDiskInfo(output,controllerid)
|
arraydisk = returnDiskInfo(output,controllerid)
|
||||||
for array in arraydisk:
|
for array in arraydisk:
|
||||||
dbgprint('Disk c'+str(controllerid)+'u'+array[0]+'p'+array[1] + ' status : ' + array[5])
|
dbgprint('Disk c'+str(controllerid)+'u'+array[0]+'p'+array[1] + ' status : ' + array[5])
|
||||||
if array[5] not in [ 'Online', 'Online, Spun Up' ]:
|
if not array[5] == 'Online' and not array[5] == 'Online, Spun Up':
|
||||||
bad = True
|
bad = True
|
||||||
nagiosbaddisk=nagiosbaddisk+1
|
nagiosbaddisk=nagiosbaddisk+1
|
||||||
else:
|
else:
|
||||||
nagiosgooddisk=nagiosgooddisk+1
|
nagiosgooddisk=nagiosgooddisk+1
|
||||||
|
|
||||||
|
if ( returnWdthFromArrayCol(arraydisk,0) > dlen):
|
||||||
|
dlen = returnWdthFromArrayCol(arraydisk,0)
|
||||||
if ( returnWdthFromArrayCol(arraydisk,3) > mlen):
|
if ( returnWdthFromArrayCol(arraydisk,3) > mlen):
|
||||||
mlen = returnWdthFromArrayCol(arraydisk,3)
|
mlen = returnWdthFromArrayCol(arraydisk,3)
|
||||||
if ( returnWdthFromArrayCol(arraydisk,5) > flen):
|
if ( returnWdthFromArrayCol(arraydisk,5) > flen):
|
||||||
@ -671,7 +709,7 @@ if totaldrivenumber:
|
|||||||
arraydisk = returnDiskInfo(output,controllerid)
|
arraydisk = returnDiskInfo(output,controllerid)
|
||||||
|
|
||||||
# Adjust print format with width computed above
|
# Adjust print format with width computed above
|
||||||
drvfmt = "%-7s | %-4s | %-"+str(mlen)+"s | %-8s | %-"+str(flen)+"s | %-8s | %-4s | %-8s | %-8s"
|
drvfmt = "%-"+str(dlen+5)+"s | %-4s | %-"+str(mlen)+"s | %-8s | %-"+str(flen)+"s | %-8s | %-4s | %-8s | %-8s"
|
||||||
for array in arraydisk:
|
for array in arraydisk:
|
||||||
# Header
|
# Header
|
||||||
if ( i == 0 ):
|
if ( i == 0 ):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user