From b4cc81834734e81d0397719c14ddd4853e0cc98f Mon Sep 17 00:00:00 2001 From: yosefy Date: Mon, 1 Jul 2019 12:53:50 +0300 Subject: [PATCH] fix for 'Celsius' spelling problem in storcli.py (#1408) Signed-off-by: yosefy --- text_collector_examples/storcli.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/text_collector_examples/storcli.py b/text_collector_examples/storcli.py index 26f4bbd3..ed279e66 100755 --- a/text_collector_examples/storcli.py +++ b/text_collector_examples/storcli.py @@ -48,6 +48,8 @@ def main(args): for controller in data: response = controller['Response Data'] + + handle_common_controller(response) if response['Version']['Driver Name'] == 'megaraid_sas': handle_megaraid_controller(response) elif response['Version']['Driver Name'] == 'mpt3sas': @@ -57,6 +59,13 @@ def main(args): print_all_metrics(metric_list) +def handle_common_controller(response): + (controller_index, baselabel) = get_basic_controller_info(response) + + # Split up string to not trigger CodeSpell issues + if 'ROC temperature(Degree Celc' + 'ius)' in response['HwCfg'].keys(): + response['HwCfg']['ROC temperature(Degree Celsius)'] = response['HwCfg'].pop('ROC temperature(Degree Celc' + 'ius)') + add_metric('temperature', baselabel, int(response['HwCfg']['ROC temperature(Degree Celsius)'])) def handle_sas_controller(response): (controller_index, baselabel) = get_basic_controller_info(response) @@ -69,9 +78,7 @@ def handle_sas_controller(response): len(response['Physical Device Information'].keys()) / 2) except AttributeError: pass - # Split up string to not trigger CodeSpell issues - add_metric('temperature', baselabel, - int(response['HwCfg']['ROC temperature(Degree Celc' + 'ius)'])) + for key, basic_disk_info in response['Physical Device Information'].items(): if 'Detailed Information' in key: continue @@ -94,7 +101,6 @@ def handle_megaraid_controller(response): add_metric('ports', baselabel, response['HwCfg']['Backend Port Count']) add_metric('scheduled_patrol_read', baselabel, int('hrs' in response['Scheduled Tasks']['Patrol Read Reoccurrence'])) - add_metric('temperature', baselabel, int(response['HwCfg']['ROC temperature(Degree Celsius)'])) for cvidx, cvinfo in enumerate(response['Cachevault_Info']): add_metric('cv_temperature', baselabel + ',cvidx="' + str(cvidx) + '"', int(cvinfo['Temp'].replace('C','')))