From 583ec5e295c2fab26a7b65386b1c587704bc92fb Mon Sep 17 00:00:00 2001 From: "Vincent S. Cojot" Date: Wed, 20 Jan 2016 11:58:48 -0500 Subject: [PATCH] [megaclisas-status] Enhance display of rebuild progress for single drive. --- wrapper-scripts/megaclisas-status | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index c8f4385..6785b39 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -139,6 +139,15 @@ def returnTotalDriveNumber(output): if re.match(r'Number of Physical Drives on Adapter.*$',line.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): confdrives = 0 unconfdrives = 0 @@ -349,10 +358,12 @@ def returnDiskInfo(output,controllerid): lsidid = 'Unknown' table = [] fstate = 'Offline' + substate = 'Unknown' model = 'Unknown' speed = 'Unknown' dsize = 'Unknown' temp = 'Unk0C' + percent = 0 for line in output: if re.match(r'^Span: [0-9]+ - Number of PDs:',line.strip()): spanid = line.split(':')[1].strip() @@ -382,6 +393,7 @@ def returnDiskInfo(output,controllerid): slotid = line.split(':')[1].strip() if re.match(r'Firmware state: .*$',line.strip()): fstate = line.split(':')[1].strip() + subfstate = re.sub('\(.*', '', fstate) if re.match(r'Inquiry Data: .*$',line.strip()): model = line.split(':')[1].strip() model = re.sub(' +', ' ', model) @@ -407,10 +419,17 @@ def returnDiskInfo(output,controllerid): temp = re.sub(' \(.*\)', '', temp) if model != 'Unknown': dbgprint('Disk Info: '+str(arrayid)+' '+str(diskid)+' '+str(oldenclid)) + 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)): - table.append([str(arrayid)+"s"+spanid, str(diskid), mtype, model, dsize, fstate , speed, temp, enclid, slotid, lsidid]) + arrayid = str(arrayid)+"s"+spanid else: - table.append([str(arrayid), str(diskid), mtype, model, dsize, fstate , speed, temp, enclid, slotid, lsidid]) + arrayid = str(arrayid) + table.append([arrayid, str(diskid), mtype, model, dsize, fstate , speed, temp, enclid, slotid, lsidid]) return table @@ -423,6 +442,7 @@ def returnUnconfDiskInfo(output,controllerid): lsidid = 'Unknown' table = [] fstate = 'Offline' + substate = 'Unknown' model = 'Unknown' speed = 'Unknown' mtype = 'Unknown'