mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-03 20:14:21 +02:00
Merge pull request #34 from ElCoyote27/master
[megaclisas-status] fix for Hot spare drives from Dirk Melchers + JBOD + unconf'ed drives.
This commit is contained in:
commit
ecdacddc99
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# $Id: megaclisas-status,v 1.53 2015/09/23 19:42:23 raistlin Exp $
|
# $Id: megaclisas-status,v 1.58 2016/02/11 12:55:49 root Exp root $
|
||||||
#
|
#
|
||||||
# Written by Adam Cecile <gandalf@NOSPAM.le-vert.net>
|
# Written by Adam Cecile <gandalf@NOSPAM.le-vert.net>
|
||||||
# Modified by Vincent S. Cojot <vincent@NOSPAM.cojot.name>
|
# Modified by Vincent S. Cojot <vincent@NOSPAM.cojot.name>
|
||||||
@ -25,7 +25,6 @@ printarray = True
|
|||||||
printcontroller = True
|
printcontroller = True
|
||||||
debugmode = False
|
debugmode = False
|
||||||
totaldrivenumber = 0
|
totaldrivenumber = 0
|
||||||
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) ]
|
||||||
@ -39,7 +38,7 @@ def print_usage():
|
|||||||
|
|
||||||
# We need root access to query
|
# We need root access to query
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if os.getenv('USER') != 'root':
|
if os.getenv('LOGNAME') != 'root':
|
||||||
print '# This script requires Administrator privs! e.g :\r'
|
print '# This script requires Administrator privs! e.g :\r'
|
||||||
print 'sudo '+str(sys.argv[0])+'\r'
|
print 'sudo '+str(sys.argv[0])+'\r'
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
@ -148,14 +147,13 @@ def returnRebuildProgress(output):
|
|||||||
percent = int(tmpstr.split('%')[0].strip())
|
percent = int(tmpstr.split('%')[0].strip())
|
||||||
return percent
|
return percent
|
||||||
|
|
||||||
def returnUnconfDriveNumber(output):
|
def returnConfDriveNumber(output):
|
||||||
|
# Count the configured drives
|
||||||
confdrives = 0
|
confdrives = 0
|
||||||
unconfdrives = 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())
|
confdrives += int(line.split(':')[2].strip())
|
||||||
unconfdrives = totaldrivenumber - confdrives
|
return int(confdrives)
|
||||||
return int(unconfdrives)
|
|
||||||
|
|
||||||
def returnControllerModel(output):
|
def returnControllerModel(output):
|
||||||
for line in output:
|
for line in output:
|
||||||
@ -255,7 +253,7 @@ def returnHBAInfo(table,output,controllerid):
|
|||||||
if controllermodel != 'Unknown':
|
if controllermodel != 'Unknown':
|
||||||
table.append([ 'c'+str(controllerid), controllermodel, controllerram, str(controllertemp), str(controllerbbu), str('FW: '+controllerrev) ])
|
table.append([ 'c'+str(controllerid), controllermodel, controllerram, str(controllertemp), str(controllerbbu), str('FW: '+controllerrev) ])
|
||||||
|
|
||||||
def returnArrayInfo(output,controllerid,arrayid):
|
def returnArrayInfo(output,controllerid,arrayid,arrayindex):
|
||||||
id = 'c'+str(controllerid)+'u'+str(arrayid)
|
id = 'c'+str(controllerid)+'u'+str(arrayid)
|
||||||
operationlinennumber = False
|
operationlinennumber = False
|
||||||
linenumber = 0
|
linenumber = 0
|
||||||
@ -331,12 +329,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
|
NestedLDTable[controllerid][arrayindex] = 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
|
NestedLDTable[controllerid][arrayindex] = True
|
||||||
else:
|
else:
|
||||||
raidtype = str('RAID-' + str(raidlvl))
|
raidtype = str('RAID-' + str(raidlvl))
|
||||||
else:
|
else:
|
||||||
@ -350,6 +348,7 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
|
|
||||||
def returnDiskInfo(output,controllerid):
|
def returnDiskInfo(output,controllerid):
|
||||||
arrayid = False
|
arrayid = False
|
||||||
|
arrayindex = -1
|
||||||
sarrayid = 'Unknown'
|
sarrayid = 'Unknown'
|
||||||
diskid = False
|
diskid = False
|
||||||
oldenclid = False
|
oldenclid = False
|
||||||
@ -385,6 +384,7 @@ def returnDiskInfo(output,controllerid):
|
|||||||
dsize = re.sub(' \[.*\.*$', '', dsize)
|
dsize = re.sub(' \[.*\.*$', '', dsize)
|
||||||
dsize = re.sub('[0-9][0-9] GB', ' Gb', dsize)
|
dsize = re.sub('[0-9][0-9] GB', ' Gb', dsize)
|
||||||
if re.match(r'^Virtual Drive: [0-9]+.*$',line.strip()):
|
if re.match(r'^Virtual Drive: [0-9]+.*$',line.strip()):
|
||||||
|
arrayindex += 1
|
||||||
arrayid = line.split('(')[0].split(':')[1].strip()
|
arrayid = line.split('(')[0].split(':')[1].strip()
|
||||||
if re.match(r'PD: [0-9]+ Information.*$',line.strip()):
|
if re.match(r'PD: [0-9]+ Information.*$',line.strip()):
|
||||||
diskid = line.split()[1].strip()
|
diskid = line.split()[1].strip()
|
||||||
@ -426,7 +426,7 @@ def returnDiskInfo(output,controllerid):
|
|||||||
percent = returnRebuildProgress(output)
|
percent = returnRebuildProgress(output)
|
||||||
fstate = str('Rebuilding (%d%%)' % (percent))
|
fstate = str('Rebuilding (%d%%)' % (percent))
|
||||||
|
|
||||||
if (( NestedLDTable[controllerid][int(arrayid)] == True) and (spanid != False)):
|
if (( NestedLDTable[controllerid][int(arrayindex)] == True) and (spanid != False)):
|
||||||
sarrayid = str(arrayid)+"s"+spanid
|
sarrayid = str(arrayid)+"s"+spanid
|
||||||
else:
|
else:
|
||||||
sarrayid = str(arrayid)
|
sarrayid = str(arrayid)
|
||||||
@ -564,7 +564,7 @@ if printarray:
|
|||||||
mlen = 0
|
mlen = 0
|
||||||
rlen = 0
|
rlen = 0
|
||||||
while controllerid < controllernumber:
|
while controllerid < controllernumber:
|
||||||
arrayid = 0
|
arrayindex = 0
|
||||||
|
|
||||||
cmd = '%s -LDInfo -lall -a%d -NoLog' % (megaclipath, controllerid)
|
cmd = '%s -LDInfo -lall -a%d -NoLog' % (megaclipath, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
@ -583,21 +583,21 @@ if printarray:
|
|||||||
ldcount += 1
|
ldcount += 1
|
||||||
ldid += 1
|
ldid += 1
|
||||||
|
|
||||||
while arrayid < arraynumber:
|
while arrayindex < arraynumber:
|
||||||
ldid = LDTable[controllerid][arrayid]
|
ldid = LDTable[controllerid][arrayindex]
|
||||||
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid)
|
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arrayinfo = returnArrayInfo(output, controllerid, ldid)
|
arrayinfo = returnArrayInfo(output, controllerid, ldid, arrayindex)
|
||||||
if ( len(arrayinfo[4]) > mlen):
|
if ( len(arrayinfo[4]) > mlen):
|
||||||
mlen = len(arrayinfo[4])
|
mlen = len(arrayinfo[4])
|
||||||
if ( len(arrayinfo[1]) > rlen):
|
if ( len(arrayinfo[1]) > rlen):
|
||||||
rlen = len(arrayinfo[1])
|
rlen = len(arrayinfo[1])
|
||||||
arrayid += 1
|
arrayindex += 1
|
||||||
controllerid += 1
|
controllerid += 1
|
||||||
|
|
||||||
controllerid = 0
|
controllerid = 0
|
||||||
while controllerid < controllernumber:
|
while controllerid < controllernumber:
|
||||||
arrayid = 0
|
arrayindex = 0
|
||||||
|
|
||||||
cmd = '%s -AdpGetPciInfo -a%d -NoLog' % (megaclipath, controllerid)
|
cmd = '%s -AdpGetPciInfo -a%d -NoLog' % (megaclipath, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
@ -606,11 +606,11 @@ if printarray:
|
|||||||
cmd = '%s -LDInfo -lall -a%d -NoLog' % (megaclipath, controllerid)
|
cmd = '%s -LDInfo -lall -a%d -NoLog' % (megaclipath, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arraynumber = returnArrayNumber(output)
|
arraynumber = returnArrayNumber(output)
|
||||||
while arrayid < arraynumber:
|
while arrayindex < arraynumber:
|
||||||
ldid = LDTable[controllerid][arrayid]
|
ldid = LDTable[controllerid][arrayindex]
|
||||||
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid)
|
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arrayinfo = returnArrayInfo(output,controllerid, ldid)
|
arrayinfo = returnArrayInfo(output,controllerid, ldid, arrayindex)
|
||||||
|
|
||||||
if pcipath:
|
if pcipath:
|
||||||
diskprefix = str('/dev/disk/by-path/pci-' + pcipath + '-scsi-0:')
|
diskprefix = str('/dev/disk/by-path/pci-' + pcipath + '-scsi-0:')
|
||||||
@ -643,7 +643,7 @@ if printarray:
|
|||||||
nagiosbadarray=nagiosbadarray+1
|
nagiosbadarray=nagiosbadarray+1
|
||||||
else:
|
else:
|
||||||
nagiosgoodarray=nagiosgoodarray+1
|
nagiosgoodarray=nagiosgoodarray+1
|
||||||
arrayid += 1
|
arrayindex += 1
|
||||||
i += 1
|
i += 1
|
||||||
controllerid += 1
|
controllerid += 1
|
||||||
if not nagiosmode:
|
if not nagiosmode:
|
||||||
@ -731,10 +731,19 @@ if totaldrivenumber:
|
|||||||
print ''
|
print ''
|
||||||
|
|
||||||
controllerid = 0
|
controllerid = 0
|
||||||
|
totalconfdrivenumber = 0
|
||||||
|
totalunconfdrivenumber = 0
|
||||||
|
totaldrivenumber = 0
|
||||||
while controllerid < controllernumber:
|
while controllerid < controllernumber:
|
||||||
cmd = '%s -LdPdInfo -a%d -NoLog' % (megaclipath, controllerid)
|
cmd = '%s -LdPdInfo -a%d -NoLog' % (megaclipath, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
totalunconfdrivenumber += returnUnconfDriveNumber(output)
|
totalconfdrivenumber = returnConfDriveNumber(output)
|
||||||
|
|
||||||
|
cmd = '%s -PDGetNum -a%d -NoLog' % (megaclipath, controllerid)
|
||||||
|
output = getOutput(cmd)
|
||||||
|
totaldrivenumber = returnTotalDriveNumber(output)
|
||||||
|
totalunconfdrivenumber += totaldrivenumber - totalconfdrivenumber
|
||||||
|
|
||||||
controllerid += 1
|
controllerid += 1
|
||||||
|
|
||||||
if totalunconfdrivenumber:
|
if totalunconfdrivenumber:
|
||||||
@ -756,7 +765,7 @@ if totalunconfdrivenumber:
|
|||||||
arraydisk = returnUnconfDiskInfo(output,controllerid)
|
arraydisk = returnUnconfDiskInfo(output,controllerid)
|
||||||
for array in arraydisk:
|
for array in arraydisk:
|
||||||
dbgprint('Disk c'+str(controllerid)+'uXpY status : ' + array[3])
|
dbgprint('Disk c'+str(controllerid)+'uXpY status : ' + array[3])
|
||||||
if array[3] not in [ 'Online', 'Unconfigured(good), Spun Up', 'JBOD' ]:
|
if array[3] not in [ 'Online', 'Unconfigured(good), Spun Up', 'JBOD','Hotspare, Spun Up' ]:
|
||||||
bad = True
|
bad = True
|
||||||
nagiosbaddisk=nagiosbaddisk+1
|
nagiosbaddisk=nagiosbaddisk+1
|
||||||
else:
|
else:
|
||||||
@ -766,7 +775,7 @@ if totalunconfdrivenumber:
|
|||||||
flen = returnWdthFromArrayCol(arraydisk,3)
|
flen = returnWdthFromArrayCol(arraydisk,3)
|
||||||
|
|
||||||
# Adjust print format with widths computed above
|
# Adjust print format with widths computed above
|
||||||
drvfmt = "%-7s | %-4s | %-"+str(mlen)+"s | %-8s | %-"+str(flen)+"s | %-8s | %-4s | %-8s | %-8s"
|
drvfmt = "%-7s | %-4s | %-"+str(mlen)+"s | %-8s | %-"+str(flen+2)+"s | %-8s | %-4s | %-8s | %-8s"
|
||||||
i = 0
|
i = 0
|
||||||
for array in arraydisk:
|
for array in arraydisk:
|
||||||
# Header
|
# Header
|
||||||
|
Loading…
x
Reference in New Issue
Block a user