更新时间:2021-09-18 GMT+08:00
Python代码样例
Python代码样例如下所示:
""" 用户需要根据实际情况填写user_name, password, taskId, url, data的值 """ import json import time from pprint import pprint import requests user_name = "xxx_xxxx" password = "xxxxxx" token ="xxxxxx" # 根据文档从获取token的接口中取到 taskId = 0 # 从页面获取 url = "xxxxx" # 从页面获取 data = [{ 'disk_capacity': '820.6184120178223', 'disk_media_type': 'HDD', 'disk_production': '6800V3', 'disk_data_source': 'huaweicloud', 'disk_pot': '31615', 'disk_collect_time': '20191205022933', 'disk_sn': 'disk_001', 'device_sn': 'device_001', 'disk_errorcount_nonmedium_ec': '0', 'disk_slow_type': None, 'disk_firmware_version': 'A440', 'disk_slot': '8', 'disk_manufacturer': 'HITACHI', 'disk_model': 'HUC109090CSS600', 'disk_failure_status': '0', 'disk_selftest_failure_count': '0', 'disk_glist_count': '0', 'disk_bms_count': '0', 'disk_temperature_current': '30', 'disk_temperature_reference': '85', 'r_ecsd': '0', 'r_ecpd': '0', 'r_operations': '0', 'r_ec': '0', 'r_times': '1019321', 'r_processed': '8443956112248', 'r_uce': '0', 'w_ecsd': '0', 'w_ecpd': '0', 'w_operations': '0', 'w_ec': '0', 'w_times': '158125', 'w_processed': '10701100018960', 'w_uce': '0', 'v_ecsd': '0', 'v_ecpd': '8', 'v_operations': '0', 'v_ec': '8', 'v_times': '1904211', 'v_processed': '99871936124480', 'v_uce': '0', 'disk_ie_asc': '0', 'disk_ie_ascq': '0', 'disk_dha_logic_status': None, 'disk_dha_link_status': None, 'slow_type': None, 'm_ip': '10.128.241.145', 'created_dt': '2019-12-06T04: 13: 44', 'interfacetype': 'SAS' }] request_data = { 'taskId': taskId, 'userId': user_name, 'data': data } headers = { 'X-Auth-Token': token, 'Content-Type': 'application/json' } start = time.time() response = requests.post(url=url, data=json.dumps(request_data), headers=headers, verify=False) end = time.time() try: pprint(json.loads(response.text)) print(f'predict cost time: {end-start:.4f} s') except: print(response.text) print(f'predict cost time: {end-start:.4f} s')
父主题: 硬盘故障预测接口
