Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[megaclisas-status] Adding the detection of hotspares #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions wrapper-scripts/megaclisas-status
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,25 @@ def returnArrayInfo(output,controllerid,arrayid):

return [id,type,size,state,inprogress]

def returnDiskInfo(output,controllerid):
arrayid = False
diskid = False
def returnDiskInfo(output):
enclid = False
slotnr = False
table = []
state = 'undef'
model = 'undef'
for line in output:
if re.match(r'^Virtual (Disk|Drive): [0-9]+.*$',line.strip()):
arrayid = line.split('(')[0].split(':')[1].strip()
if re.match(r'^Enclosure Device ID: [0-9]+$',line.strip()):
enclid = line.split('(')[0].split(':')[1].strip()
if re.match(r'Firmware state: .*$',line.strip()):
state = line.split(':')[1].strip()
if re.match(r'Inquiry Data: .*$',line.strip()):
model = line.split(':')[1].strip()
model = re.sub(' +', ' ', model)
if re.match(r'PD: [0-9]+ Information.*$',line.strip()):
diskid = line.split()[1].strip()
if re.match(r'Slot Number: [0-9]+$',line.strip()):
slotnr = line.split()[2].strip()

if arrayid != False and state != 'undef' and model != 'undef' and diskid != False:
table.append([str(arrayid), str(diskid), state, model])
if state != 'undef' and model != 'undef':
table.append([str(enclid), str(slotnr), state, model])
state = 'undef'
model = 'undef'

Expand Down Expand Up @@ -181,19 +181,17 @@ if not nagiosmode:
controllerid = 0
while controllerid < controllernumber:
arrayid = 0
cmd = binarypath+' -LDInfo -lall -a'+str(controllerid)+' -NoLog'
cmd = binarypath+' -PdList -a'+str(controllerid)+' -NoLog'
output = getOutput(cmd)
cmd = binarypath+' -LdPdInfo -a'+str(controllerid)+' -NoLog'
output = getOutput(cmd)
arraydisk = returnDiskInfo(output,controllerid)
arraydisk = returnDiskInfo(output)
for array in arraydisk:
if not array[2] == 'Online' and not array[2] == 'Online, Spun Up':
if not array[2] == 'Online' and not array[2] == 'Online, Spun Up' and not array[2] == 'Hotspare, Spun down' and not array[2] == 'Hotspare, Spun down':
bad=True
nagiosbaddisk=nagiosbaddisk+1
else:
nagiosgooddisk=nagiosgooddisk+1
if not nagiosmode:
print 'c'+str(controllerid)+'u'+array[0]+'p'+array[1]+' | '+array[3]+' | '+array[2]
print 'c'+str(controllerid)+'e'+array[0]+'s'+array[1]+' | '+array[3]+' | '+array[2]
controllerid += 1

if nagiosmode:
Expand Down