mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-26 15:24:01 +02:00
Very minor bugfixes (Rev 1.32)
This commit is contained in:
parent
c75c0ea89c
commit
fbc18f7401
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# $Id: megaclisas-status,v 1.31 2015/04/08 16:40:47 root Exp $
|
# $Id: megaclisas-status,v 1.32 2015/04/10 19:46:13 root Exp $
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -14,6 +14,7 @@ printcontroller = True
|
|||||||
totaldrivenumber = 0
|
totaldrivenumber = 0
|
||||||
totalunconfdrivenumber = 0
|
totalunconfdrivenumber = 0
|
||||||
tabwdth = 4
|
tabwdth = 4
|
||||||
|
LDTable = [[]]
|
||||||
|
|
||||||
def is_exe(fpath):
|
def is_exe(fpath):
|
||||||
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
||||||
@ -49,7 +50,8 @@ else:
|
|||||||
# 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('USER') != 'root':
|
||||||
print 'You can only run this script as root or with sudo, sucks I know. Blame the RAID card'
|
print '# This script requires Administrator privs! e.g :\r'
|
||||||
|
print 'sudo '+str(sys.argv[0])+'\r'
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
# Check command line arguments to enable nagios or not
|
# Check command line arguments to enable nagios or not
|
||||||
@ -161,16 +163,17 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
id = 'c'+str(controllerid)+'u'+str(arrayid)
|
id = 'c'+str(controllerid)+'u'+str(arrayid)
|
||||||
operationlinennumber = False
|
operationlinennumber = False
|
||||||
linenumber = 0
|
linenumber = 0
|
||||||
type = ''
|
raidtype = ''
|
||||||
size = ''
|
size = ''
|
||||||
state = ''
|
state = ''
|
||||||
strpsz = ''
|
strpsz = ''
|
||||||
dskcache = ''
|
dskcache = 'N/A'
|
||||||
properties = ''
|
properties = ''
|
||||||
|
spandepth = 0
|
||||||
for line in output:
|
for line in output:
|
||||||
if re.match(r'^RAID Level.*?:.*$',line.strip()):
|
if re.match(r'^RAID Level.*?:.*$',line.strip()):
|
||||||
type = 'RAID-'+line.strip().split(':')[1].split(',')[0].split('-')[1].strip()
|
# Extract the primary raid type, decide on X0 RAID level later when we hit Span Depth
|
||||||
# type = 'RAID'+line.strip().split(':')[1]
|
raidtype = 'RAID-'+line.strip().split(':')[1].split(',')[0].split('-')[1].strip()
|
||||||
if re.match(r'^Size.*?:.*$',line.strip()):
|
if re.match(r'^Size.*?:.*$',line.strip()):
|
||||||
# Size reported in MB
|
# Size reported in MB
|
||||||
if re.match(r'^.*MB$',line.strip().split(':')[1]):
|
if re.match(r'^.*MB$',line.strip().split(':')[1]):
|
||||||
@ -184,26 +187,33 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
else:
|
else:
|
||||||
size = line.strip().split(':')[1].strip('GB').strip()
|
size = line.strip().split(':')[1].strip('GB').strip()
|
||||||
size = str(int(round((float(size)))))+'G'
|
size = str(int(round((float(size)))))+'G'
|
||||||
|
if 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 ( int(spandepth) == 2 ):
|
||||||
|
raidtype = str(raidtype+'0')
|
||||||
if re.match(r'^State.*?:.*$',line.strip()):
|
if re.match(r'^State.*?:.*$',line.strip()):
|
||||||
state = line.strip().split(':')[1].strip()
|
state = line.strip().split(':')[1].strip()
|
||||||
if re.match(r'^Strip Size.*?:.*$',line.strip()):
|
if re.match(r'^Strip Size.*?:.*$',line.strip()):
|
||||||
strpsz = line.strip().split(':')[1].strip()
|
strpsz = line.strip().split(':')[1].strip()
|
||||||
if re.match(r'^Current Cache Policy.*?:.*$',line.strip()):
|
if re.match(r'^Current Cache Policy.*?:.*$',line.strip()):
|
||||||
props = line.strip().split(':')[1].strip()
|
props = line.strip().split(':')[1].strip()
|
||||||
if re.search('WriteBack', props):
|
|
||||||
properties += 'WB'
|
|
||||||
if re.match('WriteThrough', props):
|
|
||||||
properties += 'WT'
|
|
||||||
if re.search('ReadAdaptive', props):
|
if re.search('ReadAdaptive', props):
|
||||||
properties += ',Adapt'
|
properties += 'Adaptive'
|
||||||
if re.search('ReadAhead', props):
|
if re.search('ReadAhead', props):
|
||||||
properties += ',RA'
|
properties += 'RA'
|
||||||
if re.match('ReadAheadNone', props):
|
if re.match('ReadAheadNone', props):
|
||||||
properties += ',NoRA'
|
properties += 'NORA'
|
||||||
|
if re.search('WriteBack', props):
|
||||||
|
properties += ',WB'
|
||||||
|
if re.match('WriteThrough', props):
|
||||||
|
properties += ',WT'
|
||||||
if re.match(r'^Disk Cache Policy.*?:.*$',line.strip()):
|
if re.match(r'^Disk Cache Policy.*?:.*$',line.strip()):
|
||||||
props = line.strip().split(':')[1].strip()
|
props = line.strip().split(':')[1].strip()
|
||||||
if re.search('Disabled', props):
|
if re.search('Disabled', props):
|
||||||
dskcache = 'Disabled'
|
dskcache = 'Disabled'
|
||||||
|
if re.search('Disk.s Default', props):
|
||||||
|
dskcache = 'Default'
|
||||||
if re.search('Enabled', props):
|
if re.search('Enabled', props):
|
||||||
dskcache = 'Enabled'
|
dskcache = 'Enabled'
|
||||||
if re.match(r'^Ongoing Progresses.*?:.*$',line.strip()):
|
if re.match(r'^Ongoing Progresses.*?:.*$',line.strip()):
|
||||||
@ -213,7 +223,7 @@ def returnArrayInfo(output,controllerid,arrayid):
|
|||||||
inprogress = output[operationlinennumber+1]
|
inprogress = output[operationlinennumber+1]
|
||||||
else:
|
else:
|
||||||
inprogress = 'None'
|
inprogress = 'None'
|
||||||
return [id,type,size,strpsz,properties,dskcache,state,inprogress]
|
return [id,raidtype,size,strpsz,properties,dskcache,state,inprogress]
|
||||||
|
|
||||||
def returnDiskInfo(output,controllerid):
|
def returnDiskInfo(output,controllerid):
|
||||||
arrayid = False
|
arrayid = False
|
||||||
@ -406,21 +416,38 @@ if printarray:
|
|||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arraynumber = returnArrayNumber(output)
|
arraynumber = returnArrayNumber(output)
|
||||||
mlen = 0
|
mlen = 0
|
||||||
|
rlen = 0
|
||||||
|
# We need to explore each HBA to look for gaps in LD's
|
||||||
|
ldid = 0 ; ldcount = 0
|
||||||
|
while ldcount < arraynumber:
|
||||||
|
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid)
|
||||||
|
output = getOutput(cmd)
|
||||||
|
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()):
|
||||||
|
LDTable[controllerid].append ( ldid )
|
||||||
|
ldcount += 1
|
||||||
|
ldid += 1
|
||||||
|
|
||||||
while arrayid < arraynumber:
|
while arrayid < arraynumber:
|
||||||
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, arrayid, controllerid)
|
ldid = LDTable[controllerid][arrayid]
|
||||||
|
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arrayinfo = returnArrayInfo(output,controllerid,arrayid)
|
arrayinfo = returnArrayInfo(output, controllerid, ldid)
|
||||||
if ( len(arrayinfo[4]) > mlen):
|
if ( len(arrayinfo[4]) > mlen):
|
||||||
mlen = len(arrayinfo[4])
|
mlen = len(arrayinfo[4])
|
||||||
|
if ( len(arrayinfo[1]) > rlen):
|
||||||
|
rlen = len(arrayinfo[1])
|
||||||
arrayid += 1
|
arrayid += 1
|
||||||
arrayid = 0
|
arrayid = 0
|
||||||
|
|
||||||
while arrayid < arraynumber:
|
while arrayid < arraynumber:
|
||||||
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, arrayid, controllerid)
|
ldid = LDTable[controllerid][arrayid]
|
||||||
|
cmd = '%s -LDInfo -l%d -a%d -NoLog' % (megaclipath, ldid, controllerid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arrayinfo = returnArrayInfo(output,controllerid,arrayid)
|
arrayinfo = returnArrayInfo(output,controllerid, LDTable[controllerid][arrayid])
|
||||||
ldfmt = str('%-5s | %-6s | %7s | %7s | %'+str(mlen)+'s | %8s | %-7s | %-12s ')
|
ldfmt = str('%-5s | %-'+str(rlen)+'s | %7s | %7s | %'+str(mlen)+'s | %8s | %-7s | %-12s ')
|
||||||
# Header
|
# Header
|
||||||
if ( i == 0 ):
|
if ( i == 0 ):
|
||||||
print ldfmt % ("-- ID", "Type", "Size", "Strpsz", "Flags", "DskCache", "Status", "InProgress" )
|
print ldfmt % ("-- ID", "Type", "Size", "Strpsz", "Flags", "DskCache", "Status", "InProgress" )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user