From 62b407a2d06d041457ca69e0f9179a5a94ec5f06 Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Wed, 10 Feb 2016 10:57:06 +0100 Subject: [PATCH 01/17] Fix uudecode calls for newer releases --- packaging/debian/lsiutil/changelog | 6 ++++++ packaging/debian/lsiutil/rules | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packaging/debian/lsiutil/changelog b/packaging/debian/lsiutil/changelog index fc0f793..3d4a1ba 100644 --- a/packaging/debian/lsiutil/changelog +++ b/packaging/debian/lsiutil/changelog @@ -1,3 +1,9 @@ +lsiutil (1.60-2) unstable; urgency=medium + + * Invert uudecode file and args to get it working with newer version. + + -- Adam Cécile (Le_Vert) Wed, 10 Feb 2016 10:37:59 +0100 + lsiutil (1.60-1) unstable; urgency=low * Initial release. diff --git a/packaging/debian/lsiutil/rules b/packaging/debian/lsiutil/rules index 8948667..d3188ae 100755 --- a/packaging/debian/lsiutil/rules +++ b/packaging/debian/lsiutil/rules @@ -3,7 +3,7 @@ DESTDIR = $(CURDIR)/debian/lsiutil debian/user_guide.pdf: - uudecode $@.uu -o $@ + uudecode -o $@ $@.uu build: debian/user_guide.pdf From dbdd57023a9037734dca69187c44edce4499305e Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Wed, 10 Feb 2016 11:08:26 +0100 Subject: [PATCH 02/17] Release 0.10 megaclisas-status --- packaging/debian/megaclisas-status/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packaging/debian/megaclisas-status/changelog b/packaging/debian/megaclisas-status/changelog index 47fc702..bf8c639 100644 --- a/packaging/debian/megaclisas-status/changelog +++ b/packaging/debian/megaclisas-status/changelog @@ -1,3 +1,10 @@ +megaclisas-status (0.10) unstable; urgency=medium + + * New version including tones of fixes and improvements by + Vincent S. Cojot, thanks a lot ! + + -- Adam Cécile Wed, 10 Feb 2016 11:05:41 +0100 + megaclisas-status (0.9) unstable; urgency=low * Fix the duplicate disk issue (Closes: #26). From 5b030031b3d047fccab31e7c64887d7756f42fa9 Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Wed, 10 Feb 2016 11:15:45 +0100 Subject: [PATCH 03/17] Release sas2ircu-status 0.7 --- packaging/debian/sas2ircu-status/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packaging/debian/sas2ircu-status/changelog b/packaging/debian/sas2ircu-status/changelog index cf007a8..741d45e 100644 --- a/packaging/debian/sas2ircu-status/changelog +++ b/packaging/debian/sas2ircu-status/changelog @@ -1,3 +1,9 @@ +sas2ircu-status (0.7) unstable; urgency=medium + + * New release with better disk handling (Closes: GitHub#23). + + -- Adam Cécile (Le_Vert) Mon, 14 Dec 2015 08:48:12 +0100 + sas2ircu-status (0.6) unstable; urgency=medium * Reset disk list after each array processing (Closes: #287). From 530b024ab06fe5fa00439182da69e2a957d3883a Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Wed, 10 Feb 2016 12:31:51 +0100 Subject: [PATCH 04/17] Revert "[megaclisas-status] bug fix : properly detect unconfigured drives when they were previously part of an array" This reverts commit 517b2d35cdcb18ef94ae6fb1617d323cbfc3accf. --- wrapper-scripts/megaclisas-status | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index 2a73dff..c212e03 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -151,12 +151,9 @@ def returnRebuildProgress(output): def returnUnconfDriveNumber(output): confdrives = 0 unconfdrives = 0 - totaldrivenumber = 0 for line in output: if re.match(r'.*Number of PDs:.*$',line.strip()): - totaldrivenumber += int(line.split(':')[2].strip()) - if re.match(r'^Firmware state:.*$',line.strip()): - confdrives += 1 + confdrives += int(line.split(':')[2].strip()) unconfdrives = totaldrivenumber - confdrives return int(unconfdrives) From d95f38d6ec95043d1636fe2adede095f1b3823a3 Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Wed, 10 Feb 2016 12:34:06 +0100 Subject: [PATCH 05/17] Release megaclisas-status 0.11 --- packaging/debian/megaclisas-status/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packaging/debian/megaclisas-status/changelog b/packaging/debian/megaclisas-status/changelog index bf8c639..0619632 100644 --- a/packaging/debian/megaclisas-status/changelog +++ b/packaging/debian/megaclisas-status/changelog @@ -1,3 +1,9 @@ +megaclisas-status (0.11) unstable; urgency=medium + + * Revert a commit that broke JBOD disks reporting. + + -- Adam Cécile Wed, 10 Feb 2016 12:32:53 +0100 + megaclisas-status (0.10) unstable; urgency=medium * New version including tones of fixes and improvements by From 2db8e79d0f2ae8f0f4c487477a972734fc46d9a5 Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Wed, 10 Feb 2016 16:21:05 +0100 Subject: [PATCH 06/17] megaraid(sas)-status: hanble "ready" as a good state --- wrapper-scripts/megaraid-status | 2 +- wrapper-scripts/megaraidsas-status | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wrapper-scripts/megaraid-status b/wrapper-scripts/megaraid-status index fb877f2..a7e4d15 100644 --- a/wrapper-scripts/megaraid-status +++ b/wrapper-scripts/megaraid-status @@ -97,7 +97,7 @@ for array in arraylist: bad = True for disk in disklist: - if not disk[-1] == 'online' and not disk[-1] == 'hotspare': + if disk[-1] not in [ 'online', 'hotspare', 'ready' ]: bad = True if bad: diff --git a/wrapper-scripts/megaraidsas-status b/wrapper-scripts/megaraidsas-status index 4d428d9..f5b21e0 100644 --- a/wrapper-scripts/megaraidsas-status +++ b/wrapper-scripts/megaraidsas-status @@ -97,7 +97,7 @@ for array in arraylist: bad = True for disk in disklist: - if not disk[-1] == 'online' and not disk[-1] == 'hotspare': + if disk[-1] not in [ 'online', 'hotspare', 'ready' ]: bad = True if bad: From 4f365f0db35183d89f52a2c5ba0cd6ef5008e3ba Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Thu, 11 Feb 2016 08:09:29 +0100 Subject: [PATCH 07/17] Release megaraid-status 0.11 --- packaging/debian/megaraid-status/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packaging/debian/megaraid-status/changelog b/packaging/debian/megaraid-status/changelog index d2cfcf9..5e1a93e 100644 --- a/packaging/debian/megaraid-status/changelog +++ b/packaging/debian/megaraid-status/changelog @@ -1,3 +1,9 @@ +megaraid-status (0.11) unstable; urgency=medium + + * Handle "ready" disk status as a good one. + + -- Adam Cécile Thu, 11 Feb 2016 08:08:21 +0100 + megaraid-status (0.10) unstable; urgency=low * Update initscript from mpt-status 1.2.0-7 package (Closes: #79). From b1608526c45a3aeb19199664a03f8af1bea74b33 Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Thu, 11 Feb 2016 08:13:21 +0100 Subject: [PATCH 08/17] Seems I missed an update sometime ago --- packaging/debian/megaraid-status/changelog | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packaging/debian/megaraid-status/changelog b/packaging/debian/megaraid-status/changelog index 5e1a93e..19e99bb 100644 --- a/packaging/debian/megaraid-status/changelog +++ b/packaging/debian/megaraid-status/changelog @@ -1,9 +1,15 @@ -megaraid-status (0.11) unstable; urgency=medium - +megaraid-status (0.12) unstable; urgency=medium * Handle "ready" disk status as a good one. -- Adam Cécile Thu, 11 Feb 2016 08:08:21 +0100 +megaraid-status (0.11) unstable; urgency=medium + + * Handle disks without enclosure ID (patch by Pat Suwalski + ) + + -- Adam Cécile (Le_Vert) Sat, 14 Dec 2013 14:47:29 +0100 + megaraid-status (0.10) unstable; urgency=low * Update initscript from mpt-status 1.2.0-7 package (Closes: #79). From 6d0915ffea46e3610dbc155b642fa260daf2809b Mon Sep 17 00:00:00 2001 From: "Vincent S. Cojot" Date: Thu, 11 Feb 2016 08:59:50 -0500 Subject: [PATCH 09/17] [megaclisas-status] fix for Hot spare drives from Dirk Melchers [megaclisas-status] Fix for nested arrays from dnleek and fix miscalculation of unconfigured drives... --- wrapper-scripts/megaclisas-status | 55 ++++++++++++++++++------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index c212e03..34c38b0 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -1,5 +1,5 @@ #!/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 # Modified by Vincent S. Cojot @@ -25,7 +25,6 @@ printarray = True printcontroller = True debugmode = False 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. LDTable = [ [] * 16 for i in range(16) ] @@ -148,14 +147,13 @@ def returnRebuildProgress(output): percent = int(tmpstr.split('%')[0].strip()) return percent -def returnUnconfDriveNumber(output): +def returnConfDriveNumber(output): + # Count the configured drives confdrives = 0 - unconfdrives = 0 for line in output: if re.match(r'.*Number of PDs:.*$',line.strip()): confdrives += int(line.split(':')[2].strip()) - unconfdrives = totaldrivenumber - confdrives - return int(unconfdrives) + return int(confdrives) def returnControllerModel(output): for line in output: @@ -255,7 +253,7 @@ def returnHBAInfo(table,output,controllerid): if controllermodel != 'Unknown': 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) operationlinennumber = False linenumber = 0 @@ -331,12 +329,12 @@ def returnArrayInfo(output,controllerid,arrayid): # Compute the RAID level if (int(spandepth) >= 2): raidtype = str('RAID-' + str(raidlvl) + '0') - NestedLDTable[controllerid][arrayid] = True + NestedLDTable[controllerid][arrayindex] = True else: if(raidlvl == 1): if(diskperspan > 2): raidtype = str('RAID-10') - NestedLDTable[controllerid][arrayid] = True + NestedLDTable[controllerid][arrayindex] = True else: raidtype = str('RAID-' + str(raidlvl)) else: @@ -350,6 +348,7 @@ def returnArrayInfo(output,controllerid,arrayid): def returnDiskInfo(output,controllerid): arrayid = False + arrayindex = -1 sarrayid = 'Unknown' diskid = False oldenclid = False @@ -385,6 +384,7 @@ def returnDiskInfo(output,controllerid): dsize = re.sub(' \[.*\.*$', '', dsize) dsize = re.sub('[0-9][0-9] GB', ' Gb', dsize) if re.match(r'^Virtual Drive: [0-9]+.*$',line.strip()): + arrayindex += 1 arrayid = line.split('(')[0].split(':')[1].strip() if re.match(r'PD: [0-9]+ Information.*$',line.strip()): diskid = line.split()[1].strip() @@ -426,7 +426,7 @@ def returnDiskInfo(output,controllerid): percent = returnRebuildProgress(output) 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 else: sarrayid = str(arrayid) @@ -564,7 +564,7 @@ if printarray: mlen = 0 rlen = 0 while controllerid < controllernumber: - arrayid = 0 + arrayindex = 0 cmd = '%s -LDInfo -lall -a%d -NoLog' % (megaclipath, controllerid) output = getOutput(cmd) @@ -583,21 +583,21 @@ if printarray: ldcount += 1 ldid += 1 - while arrayid < arraynumber: - ldid = LDTable[controllerid][arrayid] + while arrayindex < arraynumber: + ldid = LDTable[controllerid][arrayindex] cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid) output = getOutput(cmd) - arrayinfo = returnArrayInfo(output, controllerid, ldid) + arrayinfo = returnArrayInfo(output, controllerid, ldid, arrayindex) if ( len(arrayinfo[4]) > mlen): mlen = len(arrayinfo[4]) if ( len(arrayinfo[1]) > rlen): rlen = len(arrayinfo[1]) - arrayid += 1 + arrayindex += 1 controllerid += 1 controllerid = 0 while controllerid < controllernumber: - arrayid = 0 + arrayindex = 0 cmd = '%s -AdpGetPciInfo -a%d -NoLog' % (megaclipath, controllerid) output = getOutput(cmd) @@ -606,11 +606,11 @@ if printarray: cmd = '%s -LDInfo -lall -a%d -NoLog' % (megaclipath, controllerid) output = getOutput(cmd) arraynumber = returnArrayNumber(output) - while arrayid < arraynumber: - ldid = LDTable[controllerid][arrayid] + while arrayindex < arraynumber: + ldid = LDTable[controllerid][arrayindex] cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid) output = getOutput(cmd) - arrayinfo = returnArrayInfo(output,controllerid, ldid) + arrayinfo = returnArrayInfo(output,controllerid, ldid, arrayindex) if pcipath: diskprefix = str('/dev/disk/by-path/pci-' + pcipath + '-scsi-0:') @@ -643,7 +643,7 @@ if printarray: nagiosbadarray=nagiosbadarray+1 else: nagiosgoodarray=nagiosgoodarray+1 - arrayid += 1 + arrayindex += 1 i += 1 controllerid += 1 if not nagiosmode: @@ -731,10 +731,19 @@ if totaldrivenumber: print '' controllerid = 0 +totalconfdrivenumber = 0 +totalunconfdrivenumber = 0 +totaldrivenumber = 0 while controllerid < controllernumber: cmd = '%s -LdPdInfo -a%d -NoLog' % (megaclipath, controllerid) 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 if totalunconfdrivenumber: @@ -756,7 +765,7 @@ if totalunconfdrivenumber: arraydisk = returnUnconfDiskInfo(output,controllerid) for array in arraydisk: 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 nagiosbaddisk=nagiosbaddisk+1 else: @@ -766,7 +775,7 @@ if totalunconfdrivenumber: flen = returnWdthFromArrayCol(arraydisk,3) # 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 for array in arraydisk: # Header From 2f752f4703eb1508d506ae275ab45b1ed7bc15d6 Mon Sep 17 00:00:00 2001 From: "Vincent S. Cojot" Date: Thu, 11 Feb 2016 09:13:23 -0500 Subject: [PATCH 10/17] [megaclisas-status] Fix for use under cron by Inglebard --- wrapper-scripts/megaclisas-status | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index 34c38b0..cb26fd0 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -38,7 +38,7 @@ def print_usage(): # We need root access to query if __name__ == '__main__': - if os.getenv('USER') != 'root': + if os.getenv('LOGNAME') != 'root': print '# This script requires Administrator privs! e.g :\r' print 'sudo '+str(sys.argv[0])+'\r' sys.exit(5) From 1d5d25c5d307657bfb63490e659cbe28b8ebd448 Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Tue, 16 Feb 2016 08:02:35 +0100 Subject: [PATCH 11/17] Also whitelist Hotspare, Spun down --- wrapper-scripts/megaclisas-status | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index cb26fd0..7adf269 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -765,7 +765,7 @@ if totalunconfdrivenumber: arraydisk = returnUnconfDiskInfo(output,controllerid) for array in arraydisk: dbgprint('Disk c'+str(controllerid)+'uXpY status : ' + array[3]) - if array[3] not in [ 'Online', 'Unconfigured(good), Spun Up', 'JBOD','Hotspare, Spun Up' ]: + if array[3] not in [ 'Online', 'Unconfigured(good), Spun Up', 'JBOD','Hotspare, Spun Up','Hotspare, Spun down' ]: bad = True nagiosbaddisk=nagiosbaddisk+1 else: From f470411f32b98f07227d84d587fe79a8063aa103 Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Tue, 16 Feb 2016 08:22:28 +0100 Subject: [PATCH 12/17] Release megaclisas-status 0.12 --- packaging/debian/megaclisas-status/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packaging/debian/megaclisas-status/changelog b/packaging/debian/megaclisas-status/changelog index 0619632..3b68b37 100644 --- a/packaging/debian/megaclisas-status/changelog +++ b/packaging/debian/megaclisas-status/changelog @@ -1,3 +1,9 @@ +megaclisas-status (0.12) unstable; urgency=medium + + * New release including indexes fixes and hotspare handling. + + -- Adam Cécile Tue, 16 Feb 2016 08:03:40 +0100 + megaclisas-status (0.11) unstable; urgency=medium * Revert a commit that broke JBOD disks reporting. From a47b3fdd4529b92be0063440ef84ea408d9da1e3 Mon Sep 17 00:00:00 2001 From: "Vincent S. Cojot" Date: Wed, 17 Feb 2016 08:19:12 -0500 Subject: [PATCH 13/17] [megaclisas-status] Change from os.getenv to os.geteuid --- wrapper-scripts/megaclisas-status | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index 7adf269..af55941 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -38,8 +38,9 @@ def print_usage(): # We need root access to query if __name__ == '__main__': - if os.getenv('LOGNAME') != 'root': - print '# This script requires Administrator privs! e.g :\r' + myuid = os.geteuid() + if myuid != 0: + print '# This script requires Administrator privs (Current EUID: '+str(myuid)+'! e.g :\r' print 'sudo '+str(sys.argv[0])+'\r' sys.exit(5) From 4bfc7d7dfb4dfa6265fc860d09fe34254a96f25a Mon Sep 17 00:00:00 2001 From: Adam Cecile Date: Thu, 18 Feb 2016 11:28:02 +0100 Subject: [PATCH 14/17] megaclisas-status 0.13 --- packaging/debian/megaclisas-status/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packaging/debian/megaclisas-status/changelog b/packaging/debian/megaclisas-status/changelog index 3b68b37..f2e5cf2 100644 --- a/packaging/debian/megaclisas-status/changelog +++ b/packaging/debian/megaclisas-status/changelog @@ -1,3 +1,9 @@ +megaclisas-status (0.13) unstable; urgency=medium + + * Fix root privileges detection. + + -- Adam Cécile Thu, 18 Feb 2016 11:26:29 +0100 + megaclisas-status (0.12) unstable; urgency=medium * New release including indexes fixes and hotspare handling. From 26094a11b399abc401590f06951ff826a1a41be4 Mon Sep 17 00:00:00 2001 From: "Vincent S. Cojot" Date: Thu, 18 Feb 2016 16:01:50 -0500 Subject: [PATCH 15/17] [megaclisas-status] Minor fix when MegaCli* is not found in the PATH... --- wrapper-scripts/megaclisas-status | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index af55941..35b0afe 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -90,18 +90,21 @@ for megabin in "MegaCli64","MegaCli","megacli": dbgprint ('Looking for '+str(megabin)+' in PATH next..') megaclipath = which(megabin) if (megaclipath != None): + dbgprint ('Will use MegaCLI from here: '+str(megaclipath)) break - else: - dbgprint ('Found MegaCLI here: '+str(megaclipath)) # Check binary exists (and +x), if not print an error message -if os.path.exists(megaclipath) and os.access(megaclipath, os.X_OK): - pass -else: - if nagiosmode: - print 'UNKNOWN - Cannot find '+megaclipath +if (megaclipath != None): + if os.path.exists(megaclipath) and os.access(megaclipath, os.X_OK): + pass else: - print 'Cannot find ' + megaclipath + 'in your PATH. Please install it.' + if nagiosmode: + print 'UNKNOWN - Cannot find '+megaclipath + else: + print 'Cannot find ' + megaclipath + 'in your PATH. Please install it.' + sys.exit(3) +else: + print 'Cannot find "MegaCli64","MegaCli" or "megacli" in your PATH. Please install it.' sys.exit(3) From 8bde9b05f69929203af239d7f65fc050f1eade5a Mon Sep 17 00:00:00 2001 From: "Vincent S. Cojot" Date: Thu, 18 Feb 2016 23:52:38 -0500 Subject: [PATCH 16/17] [megaclisas-status] Initial attempt at supporting Cache Cade drives... --- wrapper-scripts/megaclisas-status | 115 ++++++++++++++++++------------ 1 file changed, 68 insertions(+), 47 deletions(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index 35b0afe..ca987b0 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -271,14 +271,16 @@ def returnArrayInfo(output,controllerid,arrayid,arrayindex): properties = '' spandepth = 0 diskperspan = 0 + cachecade_info = 'None' + for line in output: if re.match(r'^Virtual Drive:.*(Target Id: [0-9]+).*$',line.strip()): # Extract the SCSI Target ID targetid = line.strip().split(':')[2].split(')')[0].strip() - if re.match(r'^RAID Level.*?:.*$',line.strip()): + elif re.match(r'^RAID Level.*?:.*$',line.strip()): # Extract the primary raid type, decide on X0 RAID level later when we hit Span Depth raidlvl = int(line.strip().split(':')[1].split(',')[0].split('-')[1].strip()) - if re.match(r'^Size.*?:.*$',line.strip()): + elif re.match(r'^Size.*?:.*$',line.strip()): # Size reported in MB if re.match(r'^.*MB$',line.strip().split(':')[1]): size = line.strip().split(':')[1].strip('MB').strip() @@ -294,16 +296,16 @@ def returnArrayInfo(output,controllerid,arrayid,arrayindex): else: size = line.strip().split(':')[1].strip('GB').strip() size = str(int(round((float(size)))))+'G' - if re.match(r'^Span Depth.*?:.*$',line.strip()): + elif re.match(r'^Span Depth.*?:.*$',line.strip()): # If Span Depth is greater than 1 chances are we have a RAID 10, 50 or 60 spandepth = line.strip().split(':')[1].strip() - if re.match(r'^State.*?:.*$',line.strip()): + elif re.match(r'^State.*?:.*$',line.strip()): state = line.strip().split(':')[1].strip() - if re.match(r'^Strip Size.*?:.*$',line.strip()): + elif re.match(r'^Strip Size.*?:.*$',line.strip()): strpsz = line.strip().split(':')[1].strip() - if re.match(r'^Number Of Drives per span.*:.*$',line.strip()): + elif 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()): + elif re.match(r'^Current Cache Policy.*?:.*$',line.strip()): props = line.strip().split(':')[1].strip() if re.search('ReadAdaptive', props): properties += 'ADRA' @@ -315,7 +317,7 @@ def returnArrayInfo(output,controllerid,arrayid,arrayindex): properties += ',WB' if re.match('WriteThrough', props): properties += ',WT' - if re.match(r'^Disk Cache Policy.*?:.*$',line.strip()): + elif re.match(r'^Disk Cache Policy.*?:.*$',line.strip()): props = line.strip().split(':')[1].strip() if re.search('Disabled', props): dskcache = 'Disabled' @@ -323,13 +325,24 @@ def returnArrayInfo(output,controllerid,arrayid,arrayindex): dskcache = 'Default' if re.search('Enabled', props): dskcache = 'Enabled' - if re.match(r'^Ongoing Progresses.*?:.*$',line.strip()): + elif re.match(r'^Ongoing Progresses.*?:.*$',line.strip()): operationlinennumber = linenumber + elif re.match(r'Cache Cade Type\s*:.*$', line): + cachecade_info = "Type : %s" %(get_line_value(line)) + elif re.match(r'^Target Id of the Associated LDs\s*:.*$', line): + associated=[] + for array in line.split(':')[1].strip().split(','): + associated.append('c%du%d' % (controller_id, int(array))) + cachecade_info = "Associated : %s" %(', '.join(associated)) + linenumber += 1 - if operationlinennumber: - inprogress = output[operationlinennumber+1] - else: - inprogress = 'None' + + # If there was an ongoing operation, find the relevant line in the previous output + if operationlinennumber: + inprogress = output[operationlinennumber + 1] + else: + inprogress = 'None' + # Compute the RAID level if (int(spandepth) >= 2): raidtype = str('RAID-' + str(raidlvl) + '0') @@ -348,7 +361,7 @@ def returnArrayInfo(output,controllerid,arrayid,arrayindex): + ' Span Depth: ' + str(spandepth) + ' Disk Per Span: ' + str(diskperspan) + ' Raid Type: ' + str(raidtype)) - return [id,raidtype,size,strpsz,properties,dskcache,state,targetid,inprogress] + return [id,raidtype,size,strpsz,properties,dskcache,state,targetid,cachecade_info,inprogress] def returnDiskInfo(output,controllerid): arrayid = False @@ -372,7 +385,7 @@ def returnDiskInfo(output,controllerid): 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()): + elif 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() @@ -383,23 +396,23 @@ def returnDiskInfo(output,controllerid): temp = 'Unk0C' slotid = False lsidid = 'Unknown' - if re.match(r'^Coerced Size: ',line.strip()): + elif re.match(r'^Coerced Size: ',line.strip()): dsize = line.split(':')[1].strip() dsize = re.sub(' \[.*\.*$', '', dsize) dsize = re.sub('[0-9][0-9] GB', ' Gb', dsize) - if re.match(r'^Virtual Drive: [0-9]+.*$',line.strip()): + elif re.match(r'^(CacheCade )?Virtual (Disk|Drive): [0-9]+.*$',line.strip()): arrayindex += 1 arrayid = line.split('(')[0].split(':')[1].strip() - if re.match(r'PD: [0-9]+ Information.*$',line.strip()): + elif re.match(r'PD: [0-9]+ Information.*$',line.strip()): diskid = line.split()[1].strip() - if re.match(r'^Device Id: .*$',line.strip()): + elif re.match(r'^Device Id: .*$',line.strip()): lsidid = line.split(':')[1].strip() - if re.match(r'Slot Number: .*$',line.strip()): + elif re.match(r'Slot Number: .*$',line.strip()): slotid = line.split(':')[1].strip() - if re.match(r'Firmware state: .*$',line.strip()): + elif re.match(r'Firmware state: .*$',line.strip()): fstate = line.split(':')[1].strip() subfstate = re.sub('\(.*', '', fstate) - if re.match(r'Inquiry Data: .*$',line.strip()): + elif re.match(r'Inquiry Data: .*$',line.strip()): model = line.split(':')[1].strip() model = re.sub(' +', ' ', model) # Sub code @@ -407,7 +420,7 @@ def returnDiskInfo(output,controllerid): dtype = re.sub(manuf+' ', '', model) dtype = re.sub(' .*', '', dtype) hwserial = re.sub('.*'+dtype+' *', '', model) - if re.match(r'^Media Type: .*$',line.strip()): + elif re.match(r'^Media Type: .*$',line.strip()): mtype = line.split(':')[1].strip() if mtype == 'Hard Disk Device': mtype = 'HDD' @@ -416,9 +429,9 @@ def returnDiskInfo(output,controllerid): mtype = 'SSD' else: mtype = 'N/A' - if re.match(r'Device Speed: .*$',line.strip()): + elif re.match(r'Device Speed: .*$',line.strip()): speed = line.split(':')[1].strip() - if re.match(r'Drive Temperature :.*$',line.strip()): + elif 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) @@ -467,29 +480,29 @@ def returnUnconfDiskInfo(output,controllerid): slotid = False lsidid = 'Unknown' - if re.match(r'^Coerced Size: ',line.strip()): + elif re.match(r'^Coerced Size: ',line.strip()): dsize = line.split(':')[1].strip() dsize = re.sub(' \[.*\.*$', '', dsize) dsize = re.sub('[0-9][0-9] GB', ' Gb', dsize) - if re.match(r'^Drive.s position: DiskGroup: [0-9]+,.*$',line.strip()): + elif 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()): + elif re.match(r'^Device Id: [0-9]+.*$',line.strip()): diskid = line.split(':')[1].strip() - if re.match(r'^Device Id: .*$',line.strip()): + elif re.match(r'^Device Id: .*$',line.strip()): lsidid = line.split(':')[1].strip() - if re.match(r'Slot Number: .*$',line.strip()): + elif re.match(r'Slot Number: .*$',line.strip()): slotid = line.split(':')[1].strip() - if re.match(r'Firmware state: .*$',line.strip()): + elif re.match(r'Firmware state: .*$',line.strip()): fstate = line.split(':')[1].strip() subfstate = re.sub('\(.*', '', fstate) - if re.match(r'Inquiry Data: .*$',line.strip()): + elif re.match(r'Inquiry Data: .*$',line.strip()): model = line.split(':')[1].strip() model = re.sub(' +', ' ', model) manuf = re.sub(' .*', '', model) dtype = re.sub(manuf+' ', '', model) dtype = re.sub(' .*', '', dtype) hwserial = re.sub('.*'+dtype+' *', '', model) - if re.match(r'^Media Type: .*$',line.strip()): + elif re.match(r'^Media Type: .*$',line.strip()): mtype = line.split(':')[1].strip() if mtype == 'Hard Disk Device': mtype = 'HDD' @@ -498,16 +511,16 @@ def returnUnconfDiskInfo(output,controllerid): mtype = 'SSD' else: mtype = 'N/A' - if re.match(r'Device Speed: .*$',line.strip()): + elif re.match(r'Device Speed: .*$',line.strip()): speed = line.split(':')[1].strip() - if re.match(r'Drive Temperature :.*$',line.strip()): + elif re.match(r'Drive Temperature :.*$',line.strip()): temp = line.split(':')[1].strip() temp = re.sub('\(.*\)', '', temp) # Drive temp is amongst the last few lines matched, decide here if we add information to the table.. if arrayid == False: if subfstate == 'Unconfigured': dbgprint('Unconfigured Disk: Arrayid: '+str(arrayid)+' DiskId: '+str(diskid)+' '+str(olddiskid)+' '+str(fstate)) - if subfstate == 'Online, Spun Up': + elif subfstate == 'Online, Spun Up': dbgprint('Online Disk: Arrayid: '+str(arrayid)+' DiskId: '+str(diskid)+' '+str(olddiskid)+' '+str(fstate)) table.append([ mtype, model, dsize, fstate, speed, temp, enclid, slotid, lsidid]) return table @@ -565,8 +578,7 @@ if printarray: pcipath = '' diskpath = '' i = 0 ; j = 0 - mlen = 0 - rlen = 0 + mlen = 0 ; rlen = 0 ; clen = 0 while controllerid < controllernumber: arrayindex = 0 @@ -581,7 +593,7 @@ if printarray: for line in output: if re.match(r'^Adapter.*Virtual Drive .* Does not Exist',line.strip()): ldid += 1 - if re.match(r'^Virtual Drive:',line.strip()): + elif re.match(r'^(CacheCade )?Virtual Drive:',line.strip()): LDTable[controllerid].append ( ldid ) NestedLDTable[controllerid].append ( False ) ldcount += 1 @@ -592,10 +604,12 @@ if printarray: cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid) output = getOutput(cmd) arrayinfo = returnArrayInfo(output, controllerid, ldid, arrayindex) - if ( len(arrayinfo[4]) > mlen): - mlen = len(arrayinfo[4]) if ( len(arrayinfo[1]) > rlen): rlen = len(arrayinfo[1]) + if ( len(arrayinfo[4]) > mlen): + mlen = len(arrayinfo[4]) + if ( len(arrayinfo[8]) > clen): + clen = len(arrayinfo[8]) arrayindex += 1 controllerid += 1 @@ -625,11 +639,19 @@ if printarray: else: arrayinfo[7] = 'N/A' - ldfmt = str('%-5s | %-'+str(rlen)+'s | %7s | %7s | %'+str(mlen)+'s | %8s | %8s | %8s | %-12s ') + # Pad the string length, just to make sure it's aligned with the headers... + if (rlen < len("Type")): + rlen = len("Type") + if (mlen < len("Flags")): + mlen = len("Flags") + if (clen < len("Cache Cade")): + clen = len("Cache Cade") + + ldfmt = str('%-5s | %-'+str(rlen)+'s | %7s | %7s | %'+str(mlen)+'s | %8s | %8s | %8s | %-'+str(clen)+'s |%-12s ') # Header if ( i == 0 ): if not nagiosmode: - print ldfmt % ("-- ID", "Type", "Size", "Strpsz", "Flags", "DskCache", "Status", "OS Path", "InProgress" ) + print ldfmt % ("-- ID", "Type", "Size", "Strpsz", "Flags", "DskCache", "Status", "OS Path", "Cache Cade", "InProgress" ) if not nagiosmode: print ldfmt % ( arrayinfo[0], @@ -640,7 +662,8 @@ if printarray: arrayinfo[5], arrayinfo[6], arrayinfo[7], - arrayinfo[8]) + arrayinfo[8], + arrayinfo[9]) dbgprint("Array state : "+arrayinfo[6]) if not arrayinfo[6] == 'Optimal': bad = True @@ -665,9 +688,7 @@ if totaldrivenumber: print '-- Disk information --' i = 0 - dlen = 0 - mlen = 0 - flen = 0 + dlen = 0 ; mlen = 0 ; flen = 0 controllerid = 0 while controllerid < controllernumber: arrayid = 0 From dfc3726e363a2224b74f56e07c8055bf2806538e Mon Sep 17 00:00:00 2001 From: "Vincent S. Cojot" Date: Fri, 19 Feb 2016 10:10:24 -0500 Subject: [PATCH 17/17] [megaclisas-status] Minor typo.. --- wrapper-scripts/megaclisas-status | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrapper-scripts/megaclisas-status b/wrapper-scripts/megaclisas-status index ca987b0..719c65c 100755 --- a/wrapper-scripts/megaclisas-status +++ b/wrapper-scripts/megaclisas-status @@ -328,7 +328,7 @@ def returnArrayInfo(output,controllerid,arrayid,arrayindex): elif re.match(r'^Ongoing Progresses.*?:.*$',line.strip()): operationlinennumber = linenumber elif re.match(r'Cache Cade Type\s*:.*$', line): - cachecade_info = "Type : %s" %(get_line_value(line)) + cachecade_info = "Type : " + line.strip().split(':')[1].strip() elif re.match(r'^Target Id of the Associated LDs\s*:.*$', line): associated=[] for array in line.split(':')[1].strip().split(','):