Handle JBOD setup for storcli exporter (#1419)

* handle jbod setup

Signed-off-by: Solvik Blum <solvik.blum@dailymotion.com>
This commit is contained in:
Solvik 2019-08-02 12:38:46 +02:00 committed by Ben Kochie
parent a7452023db
commit 0b710bb0c9
1 changed files with 24 additions and 21 deletions

View File

@ -82,7 +82,7 @@ def handle_sas_controller(response):
for key, basic_disk_info in response['Physical Device Information'].items(): for key, basic_disk_info in response['Physical Device Information'].items():
if 'Detailed Information' in key: if 'Detailed Information' in key:
continue continue
create_metrcis_of_physical_drive(basic_disk_info[0], create_metrics_of_physical_drive(basic_disk_info[0],
response['Physical Device Information'], controller_index) response['Physical Device Information'], controller_index)
@ -95,9 +95,6 @@ def handle_megaraid_controller(response):
add_metric('degraded', baselabel, int(response['Status']['Controller Status'] == 'Degraded')) add_metric('degraded', baselabel, int(response['Status']['Controller Status'] == 'Degraded'))
add_metric('failed', baselabel, int(response['Status']['Controller Status'] == 'Failed')) add_metric('failed', baselabel, int(response['Status']['Controller Status'] == 'Failed'))
add_metric('healthy', baselabel, int(response['Status']['Controller Status'] == 'Optimal')) add_metric('healthy', baselabel, int(response['Status']['Controller Status'] == 'Optimal'))
add_metric('drive_groups', baselabel, response['Drive Groups'])
add_metric('virtual_drives', baselabel, response['Virtual Drives'])
add_metric('physical_drives', baselabel, response['Physical Drives'])
add_metric('ports', baselabel, response['HwCfg']['Backend Port Count']) add_metric('ports', baselabel, response['HwCfg']['Backend Port Count'])
add_metric('scheduled_patrol_read', baselabel, add_metric('scheduled_patrol_read', baselabel,
int('hrs' in response['Scheduled Tasks']['Patrol Read Reoccurrence'])) int('hrs' in response['Scheduled Tasks']['Patrol Read Reoccurrence']))
@ -113,6 +110,11 @@ def handle_megaraid_controller(response):
time_difference_seconds = abs(system_time - controller_time).seconds time_difference_seconds = abs(system_time - controller_time).seconds
add_metric('time_difference', baselabel, time_difference_seconds) add_metric('time_difference', baselabel, time_difference_seconds)
# Make sure it doesn't crash if it's a JBOD setup
if 'Drive Groups' in response.keys():
add_metric('drive_groups', baselabel, response['Drive Groups'])
add_metric('virtual_drives', baselabel, response['Virtual Drives'])
for virtual_drive in response['VD LIST']: for virtual_drive in response['VD LIST']:
vd_position = virtual_drive.get('DG/VD') vd_position = virtual_drive.get('DG/VD')
drive_group, volume_group = -1, -1 drive_group, volume_group = -1, -1
@ -128,11 +130,12 @@ def handle_megaraid_controller(response):
str(virtual_drive.get('State')).strip()) str(virtual_drive.get('State')).strip())
add_metric('vd_info', vd_info_label, 1) add_metric('vd_info', vd_info_label, 1)
add_metric('physical_drives', baselabel, response['Physical Drives'])
if response['Physical Drives'] > 0: if response['Physical Drives'] > 0:
data = get_storcli_json('/cALL/eALL/sALL show all J') data = get_storcli_json('/cALL/eALL/sALL show all J')
drive_info = data['Controllers'][controller_index]['Response Data'] drive_info = data['Controllers'][controller_index]['Response Data']
for physical_drive in response['PD LIST']: for physical_drive in response['PD LIST']:
create_metrcis_of_physical_drive(physical_drive, drive_info, controller_index) create_metrics_of_physical_drive(physical_drive, drive_info, controller_index)
def get_basic_controller_info(response): def get_basic_controller_info(response):
@ -149,7 +152,7 @@ def get_basic_controller_info(response):
return (controller_index, baselabel) return (controller_index, baselabel)
def create_metrcis_of_physical_drive(physical_drive, detailed_info_array, controller_index): def create_metrics_of_physical_drive(physical_drive, detailed_info_array, controller_index):
enclosure = physical_drive.get('EID:Slt').split(':')[0] enclosure = physical_drive.get('EID:Slt').split(':')[0]
slot = physical_drive.get('EID:Slt').split(':')[1] slot = physical_drive.get('EID:Slt').split(':')[1]