mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-23 05:44:32 +02:00
Very minor bugfixes (Rev 1.27)
This commit is contained in:
parent
b7f27e652f
commit
4a3ed5921b
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# $Id: megaclisas-status,v 1.26 2015/03/28 02:26:41 root Exp $
|
# $Id: megaclisas-status,v 1.27 2015/03/28 03:00:34 root Exp $
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -76,6 +76,13 @@ if len(sys.argv) > 1:
|
|||||||
print 'Usage: megaraid-status [-d]'
|
print 'Usage: megaraid-status [-d]'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def returnWdthFromArrayCol(glarray,idx):
|
||||||
|
maxwdth = 0
|
||||||
|
for glrow in glarray:
|
||||||
|
if ( len(glrow[idx]) > maxwdth):
|
||||||
|
maxwdth = len(glrow[idx])
|
||||||
|
return maxwdth
|
||||||
|
|
||||||
# Get command output
|
# Get command output
|
||||||
def getOutput(cmd):
|
def getOutput(cmd):
|
||||||
output = os.popen(cmd)
|
output = os.popen(cmd)
|
||||||
@ -348,17 +355,31 @@ if printarray:
|
|||||||
|
|
||||||
print '-- Array information --'
|
print '-- Array information --'
|
||||||
|
|
||||||
ldfmt = str('%-5s | %-6s | %7s | %7s | %7s | %8s | %-12s ')
|
i = 0
|
||||||
print ldfmt % ("-- ID", "Type", "Size", "Strpsz", "Flags", "Status", "InProgress" )
|
|
||||||
while controllerid < controllernumber:
|
while controllerid < controllernumber:
|
||||||
arrayid = 0
|
arrayid = 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)
|
||||||
arraynumber = returnArrayNumber(output)
|
arraynumber = returnArrayNumber(output)
|
||||||
|
mlen = 0
|
||||||
|
|
||||||
while arrayid < arraynumber:
|
while arrayid < arraynumber:
|
||||||
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, arrayid, controllerid)
|
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, arrayid, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arrayinfo = returnArrayInfo(output,controllerid,arrayid)
|
arrayinfo = returnArrayInfo(output,controllerid,arrayid)
|
||||||
|
if ( len(arrayinfo[4]) > mlen):
|
||||||
|
mlen = len(arrayinfo[4])
|
||||||
|
arrayid += 1
|
||||||
|
arrayid = 0
|
||||||
|
|
||||||
|
while arrayid < arraynumber:
|
||||||
|
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, arrayid, controllerid)
|
||||||
|
output = getOutput(cmd)
|
||||||
|
arrayinfo = returnArrayInfo(output,controllerid,arrayid)
|
||||||
|
ldfmt = str('%-5s | %-6s | %7s | %7s | %'+str(mlen)+'s | %8s | %-12s ')
|
||||||
|
# Header
|
||||||
|
if ( i == 0 ):
|
||||||
|
print ldfmt % ("-- ID", "Type", "Size", "Strpsz", "Flags", "Status", "InProgress" )
|
||||||
print ldfmt % (
|
print ldfmt % (
|
||||||
arrayinfo[0],
|
arrayinfo[0],
|
||||||
arrayinfo[1],
|
arrayinfo[1],
|
||||||
@ -370,6 +391,7 @@ if printarray:
|
|||||||
if not arrayinfo[5] == 'Optimal':
|
if not arrayinfo[5] == 'Optimal':
|
||||||
bad = True
|
bad = True
|
||||||
arrayid += 1
|
arrayid += 1
|
||||||
|
i += 1
|
||||||
controllerid += 1
|
controllerid += 1
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
@ -396,14 +418,10 @@ if totaldrivenumber:
|
|||||||
cmd = '%s -LdPdInfo -a%d -NoLog' % (megaclipath, controllerid)
|
cmd = '%s -LdPdInfo -a%d -NoLog' % (megaclipath, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arraydisk = returnDiskInfo(output,controllerid)
|
arraydisk = returnDiskInfo(output,controllerid)
|
||||||
mlen = 0
|
mlen = returnWdthFromArrayCol(arraydisk,3)
|
||||||
flen = 0
|
flen = returnWdthFromArrayCol(arraydisk,5)
|
||||||
for array in arraydisk:
|
|
||||||
if( len(array[3]) >= mlen):
|
# Adjust print format with width computed above
|
||||||
mlen = len(array[3])
|
|
||||||
if( len(array[5]) >= flen):
|
|
||||||
flen = len(array[5])
|
|
||||||
# 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)+"s | %-8s | %-4s | %-8s | %-8s"
|
||||||
i = 0
|
i = 0
|
||||||
for array in arraydisk:
|
for array in arraydisk:
|
||||||
@ -447,13 +465,9 @@ if totalunconfdrivenumber:
|
|||||||
cmd = '%s -PDList -a%d -NoLog' % (megaclipath, controllerid)
|
cmd = '%s -PDList -a%d -NoLog' % (megaclipath, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arraydisk = returnUnconfDiskInfo(output,controllerid)
|
arraydisk = returnUnconfDiskInfo(output,controllerid)
|
||||||
mlen = 0
|
mlen = returnWdthFromArrayCol(arraydisk,1)
|
||||||
flen = 0
|
flen = returnWdthFromArrayCol(arraydisk,3)
|
||||||
for array in arraydisk:
|
|
||||||
if( len(array[1]) >= mlen):
|
|
||||||
mlen = len(array[1])
|
|
||||||
if( len(array[3]) >= flen):
|
|
||||||
flen = len(array[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)+"s | %-8s | %-4s | %-8s | %-8s"
|
||||||
i = 0
|
i = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user