mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-25 23:04:44 +02:00
Very minor bugfixes (Rev 1.43)
This commit is contained in:
parent
79e420cd31
commit
bf3d2a205f
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# $Id: megaclisas-status,v 1.42 2015/04/13 18:50:42 cojot Exp $
|
# $Id: megaclisas-status,v 1.43 2015/04/13 19:22:05 cojot Exp $
|
||||||
#
|
#
|
||||||
# Written by Adam Cecile <gandalf@NOSPAM.le-vert.net>
|
# Written by Adam Cecile <gandalf@NOSPAM.le-vert.net>
|
||||||
# Modified vy Vincent S. Cojot <vincent@NOSPAM.cojot.name>
|
# Modified vy Vincent S. Cojot <vincent@NOSPAM.cojot.name>
|
||||||
@ -58,7 +58,8 @@ if len(sys.argv) > 1:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
# Functions
|
# Functions
|
||||||
def dbgprint(msg):
|
def dbgprint(msg):
|
||||||
sys.stderr.write ( str('# DEBUG : '+msg+'\n'))
|
if (debugmode):
|
||||||
|
sys.stderr.write ( str('# DEBUG : '+msg+'\n'))
|
||||||
|
|
||||||
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)
|
||||||
@ -74,11 +75,11 @@ def which(program):
|
|||||||
os.environ["PATH"] += os.pathsep + '/opt/MegaRAID/MegaCli'
|
os.environ["PATH"] += os.pathsep + '/opt/MegaRAID/MegaCli'
|
||||||
os.environ["PATH"] += os.pathsep + '/ms/dist/hwmgmt/bin'
|
os.environ["PATH"] += os.pathsep + '/ms/dist/hwmgmt/bin'
|
||||||
for path in os.environ["PATH"].split(os.pathsep):
|
for path in os.environ["PATH"].split(os.pathsep):
|
||||||
if (debugmode): dbgprint ('Looking in PATH '+str(path))
|
dbgprint ('Looking in PATH '+str(path))
|
||||||
path = path.strip('"')
|
path = path.strip('"')
|
||||||
exe_file = os.path.join(path, program)
|
exe_file = os.path.join(path, program)
|
||||||
if is_exe(exe_file):
|
if is_exe(exe_file):
|
||||||
if (debugmode): dbgprint ('Found "'+program+'" at '+exe_file)
|
dbgprint ('Found "'+program+'" at '+exe_file)
|
||||||
return exe_file
|
return exe_file
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -113,10 +114,10 @@ def returnWdthFromArrayCol(glarray,idx):
|
|||||||
def getOutput(cmd):
|
def getOutput(cmd):
|
||||||
lines = []
|
lines = []
|
||||||
if ( Outputs.has_key(cmd) ):
|
if ( Outputs.has_key(cmd) ):
|
||||||
if (debugmode): dbgprint ("Got Cached value: "+str(cmd))
|
dbgprint ("Got Cached value: "+str(cmd))
|
||||||
lines = Outputs[cmd]
|
lines = Outputs[cmd]
|
||||||
else:
|
else:
|
||||||
if (debugmode): dbgprint ("Not a Cached value: "+str(cmd))
|
dbgprint ("Not a Cached value: "+str(cmd))
|
||||||
output = os.popen(cmd)
|
output = os.popen(cmd)
|
||||||
for line in output:
|
for line in output:
|
||||||
if not re.match(r'^$',line.strip()):
|
if not re.match(r'^$',line.strip()):
|
||||||
@ -502,8 +503,12 @@ if printarray:
|
|||||||
arrayinfo[5],
|
arrayinfo[5],
|
||||||
arrayinfo[6],
|
arrayinfo[6],
|
||||||
arrayinfo[7])
|
arrayinfo[7])
|
||||||
|
dbgprint("Array state : "+arrayinfo[6])
|
||||||
if not arrayinfo[6] == 'Optimal':
|
if not arrayinfo[6] == 'Optimal':
|
||||||
bad = True
|
bad = True
|
||||||
|
nagiosbadarray=nagiosbadarray+1
|
||||||
|
else:
|
||||||
|
nagiosgoodarray=nagiosgoodarray+1
|
||||||
arrayid += 1
|
arrayid += 1
|
||||||
i += 1
|
i += 1
|
||||||
controllerid += 1
|
controllerid += 1
|
||||||
@ -535,6 +540,14 @@ 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)
|
||||||
|
for array in arraydisk:
|
||||||
|
dbgprint('Disk c'+str(controllerid)+'u'+array[0]+'p'+array[1] + ' status : ' + array[5])
|
||||||
|
if not array[5] == 'Online' and not array[5] == 'Online, Spun Up':
|
||||||
|
bad = True
|
||||||
|
nagiosbaddisk=nagiosbaddisk+1
|
||||||
|
else:
|
||||||
|
nagiosgooddisk=nagiosgooddisk+1
|
||||||
|
|
||||||
if ( returnWdthFromArrayCol(arraydisk,3) > mlen):
|
if ( returnWdthFromArrayCol(arraydisk,3) > mlen):
|
||||||
mlen = returnWdthFromArrayCol(arraydisk,3)
|
mlen = returnWdthFromArrayCol(arraydisk,3)
|
||||||
if ( returnWdthFromArrayCol(arraydisk,5) > flen):
|
if ( returnWdthFromArrayCol(arraydisk,5) > flen):
|
||||||
@ -600,6 +613,14 @@ 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)
|
||||||
|
for array in arraydisk:
|
||||||
|
dbgprint('Disk c'+str(controllerid)+'uXpY status : ' + array[3])
|
||||||
|
if not array[3] == 'Online' and not array[3] == 'Unconfigured(good), Spun Up':
|
||||||
|
bad = True
|
||||||
|
nagiosbaddisk=nagiosbaddisk+1
|
||||||
|
else:
|
||||||
|
nagiosgooddisk=nagiosgooddisk+1
|
||||||
|
|
||||||
mlen = returnWdthFromArrayCol(arraydisk,1)
|
mlen = returnWdthFromArrayCol(arraydisk,1)
|
||||||
flen = returnWdthFromArrayCol(arraydisk,3)
|
flen = returnWdthFromArrayCol(arraydisk,3)
|
||||||
|
|
||||||
@ -629,6 +650,13 @@ if totalunconfdrivenumber:
|
|||||||
if not nagiosmode:
|
if not nagiosmode:
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
if bad:
|
if nagiosmode:
|
||||||
print '\nThere is at least one disk/array in a NOT OPTIMAL state.'
|
if bad:
|
||||||
sys.exit(1)
|
print 'RAID ERROR - Arrays: OK:'+str(nagiosgoodarray)+' Bad:'+str(nagiosbadarray)+' - Disks: OK:'+str(nagiosgooddisk)+' Bad:'+str(nagiosbaddisk)
|
||||||
|
sys.exit(2)
|
||||||
|
else:
|
||||||
|
print 'RAID OK - Arrays: OK:'+str(nagiosgoodarray)+' Bad:'+str(nagiosbadarray)+' - Disks: OK:'+str(nagiosgooddisk)+' Bad:'+str(nagiosbaddisk)
|
||||||
|
else:
|
||||||
|
if bad:
|
||||||
|
print '\nThere is at least one disk/array in a NOT OPTIMAL state.'
|
||||||
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user