aboutsummaryrefslogtreecommitdiff
path: root/text_collector_examples
diff options
context:
space:
mode:
authorSolvik <solvik@solvik.fr>2019-08-02 12:38:46 +0200
committerBen Kochie <superq@gmail.com>2019-08-02 12:38:46 +0200
commit0b710bb0c95c32402477c7df0ad74c2e4f13c4d9 (patch)
treef8003aa9890b29ab60dbd0b4afe43cb8f37e6069 /text_collector_examples
parenta7452023db716c29cea821482756a55ea5b14161 (diff)
downloadprometheus_node_collector-0b710bb0c95c32402477c7df0ad74c2e4f13c4d9.tar.bz2
prometheus_node_collector-0b710bb0c95c32402477c7df0ad74c2e4f13c4d9.tar.xz
prometheus_node_collector-0b710bb0c95c32402477c7df0ad74c2e4f13c4d9.zip
Handle JBOD setup for storcli exporter (#1419)
* handle jbod setup Signed-off-by: Solvik Blum <solvik.blum@dailymotion.com>
Diffstat (limited to 'text_collector_examples')
-rwxr-xr-xtext_collector_examples/storcli.py45
1 files changed, 24 insertions, 21 deletions
diff --git a/text_collector_examples/storcli.py b/text_collector_examples/storcli.py
index ed279e6..7dc6f95 100755
--- a/text_collector_examples/storcli.py
+++ b/text_collector_examples/storcli.py
@@ -48,7 +48,7 @@ def main(args):
48 48
49 for controller in data: 49 for controller in data:
50 response = controller['Response Data'] 50 response = controller['Response Data']
51 51
52 handle_common_controller(response) 52 handle_common_controller(response)
53 if response['Version']['Driver Name'] == 'megaraid_sas': 53 if response['Version']['Driver Name'] == 'megaraid_sas':
54 handle_megaraid_controller(response) 54 handle_megaraid_controller(response)
@@ -82,7 +82,7 @@ def handle_sas_controller(response):
82 for key, basic_disk_info in response['Physical Device Information'].items(): 82 for key, basic_disk_info in response['Physical Device Information'].items():
83 if 'Detailed Information' in key: 83 if 'Detailed Information' in key:
84 continue 84 continue
85 create_metrcis_of_physical_drive(basic_disk_info[0], 85 create_metrics_of_physical_drive(basic_disk_info[0],
86 response['Physical Device Information'], controller_index) 86 response['Physical Device Information'], controller_index)
87 87
88 88
@@ -95,9 +95,6 @@ def handle_megaraid_controller(response):
95 add_metric('degraded', baselabel, int(response['Status']['Controller Status'] == 'Degraded')) 95 add_metric('degraded', baselabel, int(response['Status']['Controller Status'] == 'Degraded'))
96 add_metric('failed', baselabel, int(response['Status']['Controller Status'] == 'Failed')) 96 add_metric('failed', baselabel, int(response['Status']['Controller Status'] == 'Failed'))
97 add_metric('healthy', baselabel, int(response['Status']['Controller Status'] == 'Optimal')) 97 add_metric('healthy', baselabel, int(response['Status']['Controller Status'] == 'Optimal'))
98 add_metric('drive_groups', baselabel, response['Drive Groups'])
99 add_metric('virtual_drives', baselabel, response['Virtual Drives'])
100 add_metric('physical_drives', baselabel, response['Physical Drives'])
101 add_metric('ports', baselabel, response['HwCfg']['Backend Port Count']) 98 add_metric('ports', baselabel, response['HwCfg']['Backend Port Count'])
102 add_metric('scheduled_patrol_read', baselabel, 99 add_metric('scheduled_patrol_read', baselabel,
103 int('hrs' in response['Scheduled Tasks']['Patrol Read Reoccurrence'])) 100 int('hrs' in response['Scheduled Tasks']['Patrol Read Reoccurrence']))
@@ -113,26 +110,32 @@ def handle_megaraid_controller(response):
113 time_difference_seconds = abs(system_time - controller_time).seconds 110 time_difference_seconds = abs(system_time - controller_time).seconds
114 add_metric('time_difference', baselabel, time_difference_seconds) 111 add_metric('time_difference', baselabel, time_difference_seconds)
115 112
116 for virtual_drive in response['VD LIST']: 113 # Make sure it doesn't crash if it's a JBOD setup
117 vd_position = virtual_drive.get('DG/VD') 114 if 'Drive Groups' in response.keys():
118 drive_group, volume_group = -1, -1 115 add_metric('drive_groups', baselabel, response['Drive Groups'])
119 if vd_position: 116 add_metric('virtual_drives', baselabel, response['Virtual Drives'])
120 drive_group = vd_position.split('/')[0] 117
121 volume_group = vd_position.split('/')[1] 118 for virtual_drive in response['VD LIST']:
122 vd_baselabel = 'controller="{0}",DG="{1}",VG="{2}"'.format(controller_index, drive_group, 119 vd_position = virtual_drive.get('DG/VD')
123 volume_group) 120 drive_group, volume_group = -1, -1
124 vd_info_label = vd_baselabel + ',name="{0}",cache="{1}",type="{2}",state="{3}"'.format( 121 if vd_position:
125 str(virtual_drive.get('Name')).strip(), 122 drive_group = vd_position.split('/')[0]
126 str(virtual_drive.get('Cache')).strip(), 123 volume_group = vd_position.split('/')[1]
127 str(virtual_drive.get('TYPE')).strip(), 124 vd_baselabel = 'controller="{0}",DG="{1}",VG="{2}"'.format(controller_index, drive_group,
128 str(virtual_drive.get('State')).strip()) 125 volume_group)
129 add_metric('vd_info', vd_info_label, 1) 126 vd_info_label = vd_baselabel + ',name="{0}",cache="{1}",type="{2}",state="{3}"'.format(
127 str(virtual_drive.get('Name')).strip(),
128 str(virtual_drive.get('Cache')).strip(),
129 str(virtual_drive.get('TYPE')).strip(),
130 str(virtual_drive.get('State')).strip())
131 add_metric('vd_info', vd_info_label, 1)
130 132
133 add_metric('physical_drives', baselabel, response['Physical Drives'])
131 if response['Physical Drives'] > 0: 134 if response['Physical Drives'] > 0:
132 data = get_storcli_json('/cALL/eALL/sALL show all J') 135 data = get_storcli_json('/cALL/eALL/sALL show all J')
133 drive_info = data['Controllers'][controller_index]['Response Data'] 136 drive_info = data['Controllers'][controller_index]['Response Data']
134 for physical_drive in response['PD LIST']: 137 for physical_drive in response['PD LIST']:
135 create_metrcis_of_physical_drive(physical_drive, drive_info, controller_index) 138 create_metrics_of_physical_drive(physical_drive, drive_info, controller_index)
136 139
137 140
138def get_basic_controller_info(response): 141def get_basic_controller_info(response):
@@ -149,7 +152,7 @@ def get_basic_controller_info(response):
149 return (controller_index, baselabel) 152 return (controller_index, baselabel)
150 153
151 154
152def create_metrcis_of_physical_drive(physical_drive, detailed_info_array, controller_index): 155def create_metrics_of_physical_drive(physical_drive, detailed_info_array, controller_index):
153 enclosure = physical_drive.get('EID:Slt').split(':')[0] 156 enclosure = physical_drive.get('EID:Slt').split(':')[0]
154 slot = physical_drive.get('EID:Slt').split(':')[1] 157 slot = physical_drive.get('EID:Slt').split(':')[1]
155 158