[megaclisas-stat] Improve support for Nested RAID levels by display the span ID as well..

This commit is contained in:
Vincent S. Cojot 2016-01-14 14:15:15 -05:00
parent 17b178cb51
commit 8ef38aa659
1 changed files with 19 additions and 5 deletions

View File

@ -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.
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 = {}
@ -289,7 +290,7 @@ def returnArrayInfo(output,controllerid,arrayid):
state = line.strip().split(':')[1].strip()
if re.match(r'^Strip Size.*?:.*$',line.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())
if re.match(r'^Current Cache Policy.*?:.*$',line.strip()):
props = line.strip().split(':')[1].strip()
@ -321,10 +322,12 @@ def returnArrayInfo(output,controllerid,arrayid):
# Compute the RAID level
if (int(spandepth) >= 2):
raidtype = str('RAID-' + str(raidlvl) + '0')
NestedLDTable[controllerid][arrayid] = True
else:
if(raidlvl == 1):
if(diskperspan > 2):
raidtype = str('RAID-10')
NestedLDTable[controllerid][arrayid] = True
else:
raidtype = str('RAID-' + str(raidlvl))
else:
@ -341,6 +344,7 @@ def returnDiskInfo(output,controllerid):
diskid = False
oldenclid = False
enclid = False
spanid = False
slotid = False
lsidid = 'Unknown'
table = []
@ -350,6 +354,9 @@ def returnDiskInfo(output,controllerid):
dsize = 'Unknown'
temp = 'Unk0C'
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()):
# We match here early in the analysis so reset the vars if this is a new disk we're reading..
oldenclid = enclid
@ -399,8 +406,11 @@ def returnDiskInfo(output,controllerid):
temp = line.split(':')[1].strip()
temp = re.sub(' \(.*\)', '', temp)
if model != 'Unknown':
#### print str(arrayid)+' '+str(diskid)+' '+str(olddiskid)
table.append([str(arrayid), str(diskid), mtype, model, dsize, fstate , speed, temp, enclid, slotid, lsidid])
dbgprint('Disk Info: '+str(arrayid)+' '+str(diskid)+' '+str(oldenclid))
if ( NestedLDTable[controllerid][int(arrayid)] == True):
table.append([str(arrayid)+"s"+spanid, str(diskid), mtype, model, dsize, fstate , speed, temp, enclid, slotid, lsidid])
else:
table.append([str(arrayid), str(diskid), mtype, model, dsize, fstate , speed, temp, enclid, slotid, lsidid])
return table
@ -548,6 +558,7 @@ if printarray:
ldid += 1
if re.match(r'^Virtual Drive:',line.strip()):
LDTable[controllerid].append ( ldid )
NestedLDTable[controllerid].append ( False )
ldcount += 1
ldid += 1
@ -629,6 +640,7 @@ if totaldrivenumber:
print '-- Disk information --'
i = 0
dlen = 0
mlen = 0
flen = 0
controllerid = 0
@ -644,12 +656,14 @@ if totaldrivenumber:
arraydisk = returnDiskInfo(output,controllerid)
for array in arraydisk:
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
nagiosbaddisk=nagiosbaddisk+1
else:
nagiosgooddisk=nagiosgooddisk+1
if ( returnWdthFromArrayCol(arraydisk,0) > dlen):
dlen = returnWdthFromArrayCol(arraydisk,0)
if ( returnWdthFromArrayCol(arraydisk,3) > mlen):
mlen = returnWdthFromArrayCol(arraydisk,3)
if ( returnWdthFromArrayCol(arraydisk,5) > flen):
@ -671,7 +685,7 @@ if totaldrivenumber:
arraydisk = returnDiskInfo(output,controllerid)
# 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:
# Header
if ( i == 0 ):