mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-26 23:34:02 +02:00
Attempt to handle correctly arcconf 2.x output
This commit is contained in:
parent
0263b373c5
commit
5332a53523
@ -68,7 +68,7 @@ def returnArrayIds(output):
|
|||||||
ids.append(re.sub(r'^Logical [Dd]evice number', line).strip())
|
ids.append(re.sub(r'^Logical [Dd]evice number', line).strip())
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
def returnArrayInfo(output):
|
def returnArrayInfo(output, ctrl_id='?'):
|
||||||
members = []
|
members = []
|
||||||
for line in output:
|
for line in output:
|
||||||
# RAID level may be either N or Simple_Volume
|
# RAID level may be either N or Simple_Volume
|
||||||
@ -79,22 +79,55 @@ def returnArrayInfo(output):
|
|||||||
status = line.split(':')[1].strip()
|
status = line.split(':')[1].strip()
|
||||||
if re.match(r'^Size\s+: [0-9]+ MB$',line.strip()):
|
if re.match(r'^Size\s+: [0-9]+ MB$',line.strip()):
|
||||||
size = str(int(line.strip('MB').split(':')[1].strip()) / 1000)
|
size = str(int(line.strip('MB').split(':')[1].strip()) / 1000)
|
||||||
|
|
||||||
if re.match(r'^(Group\s[0-9]+,\s)?Segment [0-9]+\s+: .*$',line.strip()):
|
if re.match(r'^(Group\s[0-9]+,\s)?Segment [0-9]+\s+: .*$',line.strip()):
|
||||||
splitter = re.compile('(\(.*\))')
|
|
||||||
# The line can be either
|
# The line can be either (arcconf 1.x)
|
||||||
# Segment 0 : Present (Controller:1,Enclosure:0,Slot:0) JPW9J0N00RWMUV
|
# Group 0, Segment 0 : Present (Controller:1,Enclosure:0,Slot:0) JPW9J0N00RWMUV
|
||||||
# Or
|
# Group 0, Segment 0 : Present (Controller:1,Channel:0,Device:0) S13PJ1CQ719255
|
||||||
# Segment 0 : Present (Controller:1,Channel:0,Device:0) S13PJ1CQ719255
|
# Group 0; Segment 0 : Present (Controller:1,Connector:1,Device:2) 9QJ7D0MJ
|
||||||
# Or
|
#
|
||||||
# Segment 0 : Present (Controller:1,Connector:1,Device:2) 9QJ7D0MJ
|
# Or (arcconf 2.x)
|
||||||
line = re.sub('Controller:','',line)
|
# Group 0, Segment 0 : Present (953869MB, SATA, HDD, Connector:1, Device:1) JPW9K0HZ216NJL'
|
||||||
line = re.sub('(Channel|Enclosure|Connector):','',line)
|
|
||||||
line = re.sub('(Device|Slot):','',line)
|
# Cut on : and re-join everything except first part
|
||||||
line = line.split(':')[1]
|
line = ':'.join(line.split(':')[1:]).strip()
|
||||||
if re.match(r'^ Missing',line):
|
# Extract everything between ()
|
||||||
members.append('?,?')
|
device_state = re.search('\s+\((.*)\)\s+', line).group(1)
|
||||||
|
# Coma separated
|
||||||
|
device_attrs = device_state.split(',')
|
||||||
|
device_attrs = [ x.strip() for x in device_attrs ]
|
||||||
|
print(device_attrs)
|
||||||
|
# Some magic here...
|
||||||
|
# Strip out from the list element not matching Xyz:12
|
||||||
|
# Split on column: now we have and array of arrays like [['Controller', '1'], ['Connector', '1'], ['Device', '0']]
|
||||||
|
# Casting to dict will turn Controller as key and 1 as value
|
||||||
|
device_attrs = dict([ x.split(':') for x in device_attrs if re.match('\w+:\d+', x) ])
|
||||||
|
|
||||||
|
# Extract id for this device
|
||||||
|
if 'Controller' in device_attrs:
|
||||||
|
controller_id = device_attrs['Controller']
|
||||||
else:
|
else:
|
||||||
members.append(splitter.split(line)[1].strip('(').strip(')'))
|
controller_id = ctrl_id
|
||||||
|
|
||||||
|
if 'Channel' in device_attrs:
|
||||||
|
channel_id = device_attrs['Channel']
|
||||||
|
elif 'Enclosure' in device_attrs:
|
||||||
|
channel_id = device_attrs['Enclosure']
|
||||||
|
elif 'Connector' in device_attrs:
|
||||||
|
channel_id = device_attrs['Connector']
|
||||||
|
else:
|
||||||
|
channel_id = '?'
|
||||||
|
|
||||||
|
if 'Device' in device_attrs:
|
||||||
|
device_id = device_attrs['Device']
|
||||||
|
elif 'Slot' in device_attrs:
|
||||||
|
device_id = device_attrs['Slot']
|
||||||
|
else:
|
||||||
|
device_id = '?'
|
||||||
|
|
||||||
|
members.append('%s,%s,%s' % (controller_id, channel_id, device_id))
|
||||||
|
|
||||||
return [type,status,size,members]
|
return [type,status,size,members]
|
||||||
|
|
||||||
def returnControllerTasks(output):
|
def returnControllerTasks(output):
|
||||||
@ -225,7 +258,7 @@ if printarray:
|
|||||||
for arrayid in arrayids:
|
for arrayid in arrayids:
|
||||||
cmd = '"%s" GETCONFIG %s LD %s' % (arcconfpath, controllerid, arrayid)
|
cmd = '"%s" GETCONFIG %s LD %s' % (arcconfpath, controllerid, arrayid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arrayinfo = returnArrayInfo(output)
|
arrayinfo = returnArrayInfo(output, ctrl_id=controllerid)
|
||||||
if arrayinfo[1] != 'Optimal':
|
if arrayinfo[1] != 'Optimal':
|
||||||
nagiosbadarray += 1
|
nagiosbadarray += 1
|
||||||
bad = True
|
bad = True
|
||||||
@ -284,7 +317,7 @@ while controllerid <= controllernumber:
|
|||||||
for arrayid in arrayids:
|
for arrayid in arrayids:
|
||||||
cmd = '"%s" GETCONFIG %s LD %s' % (arcconfpath, controllerid, arrayid)
|
cmd = '"%s" GETCONFIG %s LD %s' % (arcconfpath, controllerid, arrayid)
|
||||||
output = getOutput(cmd)
|
output = getOutput(cmd)
|
||||||
arrayinfo = returnArrayInfo(output)
|
arrayinfo = returnArrayInfo(output, ctrl_id=controllerid)
|
||||||
|
|
||||||
# Try to attach current disk to array (loop)
|
# Try to attach current disk to array (loop)
|
||||||
memberid = 0
|
memberid = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user