[megaclisas-status] Initial attempt at adding Battery Status

This commit is contained in:
Vincent S. Cojot 2015-11-05 12:34:49 -05:00
parent 123ef59da8
commit 99ba05aabd
1 changed files with 37 additions and 4 deletions

View File

@ -174,6 +174,32 @@ def returnROCTemp(output):
else: else:
return str('N/A') return str('N/A')
def returnBBUPresence(output):
BBU = ''
tmpstr = ''
for line in output:
if re.match(r'^BBU +:.*$',line.strip()):
tmpstr = line.split(':')[1].strip()
BBU = re.sub(' +.*$', '', tmpstr)
break
if ( BBU != '' ):
return str(BBU)
else:
return str('N/A')
def returnBBUStatus(output):
BBUStatus = ''
tmpstr = ''
for line in output:
if re.match(r'^Battery Replacement required +:.*$',line.strip()):
tmpstr = line.split(':')[1].strip()
BBUStatus = re.sub(' +.*$', '', tmpstr)
break
if ( BBUStatus == 'Yes' ):
return str('REPL')
else:
return str(BBUStatus)
def returnArrayNumber(output): def returnArrayNumber(output):
i = 0 i = 0
for line in output: for line in output:
@ -210,8 +236,14 @@ def returnHBAInfo(table,output,controllerid):
controllerram = returnMemorySize(output) controllerram = returnMemorySize(output)
controllerrev = returnFirmwareVersion(output) controllerrev = returnFirmwareVersion(output)
controllertemp = returnROCTemp(output) controllertemp = returnROCTemp(output)
controllerbbu = returnBBUPresence(output)
if controllerbbu == 'Present':
cmd = '%s -AdpBbuCmd -GetBbuStatus -a%d -NoLog' % (megaclipath, controllerid)
output = getOutput(cmd)
controllerbbu = returnBBUStatus(output)
if controllermodel != 'Unknown': if controllermodel != 'Unknown':
table.append([ 'c'+str(controllerid), controllermodel, controllerram, str(controllertemp), str('FW: '+controllerrev) ]) table.append([ 'c'+str(controllerid), controllermodel, controllerram, str(controllertemp), str(controllerbbu), str('FW: '+controllerrev) ])
def returnArrayInfo(output,controllerid,arrayid): def returnArrayInfo(output,controllerid,arrayid):
id = 'c'+str(controllerid)+'u'+str(arrayid) id = 'c'+str(controllerid)+'u'+str(arrayid)
@ -470,18 +502,19 @@ if printcontroller:
controllerid = 0 controllerid = 0
for hba in hbainfo: for hba in hbainfo:
hbafmt = str('%-5s | %-'+str(mlen)+'s | %-6s | %-4s | %-12s ') hbafmt = str('%-5s | %-'+str(mlen)+'s | %-6s | %-4s | %-6s | %-12s ')
# Header # Header
if ( i == 0 ): if ( i == 0 ):
if not nagiosmode: if not nagiosmode:
print hbafmt % ("-- ID","H/W Model","RAM","Temp","Firmware") print hbafmt % ("-- ID","H/W Model","RAM","Temp","BBU", "Firmware")
if not nagiosmode: if not nagiosmode:
print hbafmt % ( print hbafmt % (
hba[0], hba[0],
hba[1], hba[1],
hba[2], hba[2],
hba[3], hba[3],
hba[4]) hba[4],
hba[5])
i += 1 i += 1
if not nagiosmode: if not nagiosmode:
print '' print ''