def test_smartctl(): expect = [{ "type": "ssd", "brand": "Crucial", "model": "CT128M550SSD3", "family": "MX100/MX200/M5x0/M600 Client SSDs", "sn": "14110C323F00", 'wwn': '5 00a075 01d3243de', "capacity-byte": 128000000000, 'smart-data': 'ok', 'sata-ports-n': 1, # TODO: this is wrong, this is mSATA "notes": "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate POSR-K 100 100 000 - 2\n 5 Reallocate_NAND_Blk_Cnt PO--CK 100 100 000 - 0\n 9 Power_On_Hours -O--CK 100 100 000 - 4767\n 12 Power_Cycle_Count -O--CK 100 100 000 - 7869\n171 Program_Fail_Count -O--CK 100 100 000 - 0\n172 Erase_Fail_Count -O--CK 100 100 000 - 0\n173 Ave_Block-Erase_Count -O--CK 095 095 000 - 177\n174 Unexpect_Power_Loss_Ct -O--CK 100 100 000 - 366\n180 Unused_Reserve_NAND_Blk PO--CK 000 000 000 - 1036\n183 SATA_Interfac_Downshift -O--CK 100 100 000 - 0\n184 Error_Correction_Count -O--CK 100 100 000 - 0\n187 Reported_Uncorrect -O--CK 100 100 000 - 0\n194 Temperature_Celsius -O---K 034 006 000 - 66 (Min/Max 17/94)\n196 Reallocated_Event_Count -O--CK 100 100 000 - 0\n197 Current_Pending_Sector -O--CK 100 100 000 - 0\n198 Offline_Uncorrectable ----CK 100 100 000 - 0\n199 UDMA_CRC_Error_Count -O--CK 100 100 000 - 0\n202 Percent_Lifetime_Used P---CK 095 095 000 - 5\n206 Write_Error_Rate -OSR-- 100 100 000 - 0\n210 Success_RAIN_Recov_Cnt -O--CK 100 100 000 - 0\n246 Total_Host_Sector_Write -O--CK 100 100 000 - 14546033643\n247 Host_Program_Page_Count -O--CK 100 100 000 - 463669262\n248 Bckgnd_Program_Page_Cnt -O--CK 100 100 000 - 910054629\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [ { "type": "ssd", "brand": "", "model": "DREVO X1 SSD", "family": "", "hdd-form-factor": "2.5-7mm", "sn": "TX1711901797", 'wwn': '0 000000 000000000', # Nice "capacity-byte": 240000000000, "human_readable_capacity": "240 GB", "smart-data": "ok", 'sata-ports-n': 1, 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate -O--CK 100 100 050 - 0\n 5 Reallocated_Sector_Ct -O--CK 100 100 050 - 52\n 9 Power_On_Hours -O--CK 100 100 050 - 1668\n 12 Power_Cycle_Count -O--CK 100 100 050 - 829\n160 Unknown_Attribute -O--CK 100 100 050 - 19\n161 Unknown_Attribute PO--CK 100 100 050 - 35\n163 Unknown_Attribute -O--CK 100 100 050 - 15\n164 Unknown_Attribute -O--CK 100 100 050 - 42113\n165 Unknown_Attribute -O--CK 100 100 050 - 114\n166 Unknown_Attribute -O--CK 100 100 050 - 10\n167 Unknown_Attribute -O--CK 100 100 050 - 79\n168 Unknown_Attribute -O--CK 100 100 050 - 3000\n169 Unknown_Attribute -O--CK 100 100 050 - 98\n175 Program_Fail_Count_Chip -O--CK 100 100 050 - 0\n176 Erase_Fail_Count_Chip -O--CK 100 100 050 - 0\n177 Wear_Leveling_Count -O--CK 100 100 050 - 0\n178 Used_Rsvd_Blk_Cnt_Chip -O--CK 100 100 050 - 52\n181 Program_Fail_Cnt_Total -O--CK 100 100 050 - 0\n182 Erase_Fail_Count_Total -O--CK 100 100 050 - 0\n192 Power-Off_Retract_Count -O--CK 100 100 050 - 68\n194 Temperature_Celsius -O---K 100 100 050 - 38\n195 Hardware_ECC_Recovered -O--CK 100 100 050 - 92762\n196 Reallocated_Event_Count -O--CK 100 100 050 - 19\n197 Current_Pending_Sector -O--CK 100 100 050 - 52\n198 Offline_Uncorrectable -O--CK 100 100 050 - 19\n199 UDMA_CRC_Error_Count -O--CK 100 100 050 - 0\n232 Available_Reservd_Space -O--CK 100 100 050 - 35\n241 Total_LBAs_Written ----CK 100 100 050 - 147066\n242 Total_LBAs_Read ----CK 100 100 050 - 238128\n245 Unknown_Attribute -O--CK 100 100 050 - 242467\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" }, { "type": "hdd", "brand": "Seagate", "model": "ST9750420AS", "family": "Momentus 7200.5", "wwn": "5 000c50 0614757a2", "sn": "6WS3155L", "capacity-decibyte": 750000000000, "human_readable_capacity": "750 GB", "spin-rate-rpm": 7200, "smart-data": "ok", 'sata-ports-n': 1, 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate POSR-- 119 099 006 - 206410160\n 3 Spin_Up_Time PO---- 098 097 085 - 0\n 4 Start_Stop_Count -O--CK 099 099 020 - 1940\n 5 Reallocated_Sector_Ct PO--CK 100 100 036 - 0\n 7 Seek_Error_Rate POSR-- 074 060 030 - 27414184\n 9 Power_On_Hours -O--CK 098 098 000 - 2017\n 10 Spin_Retry_Count PO--C- 100 100 097 - 0\n 12 Power_Cycle_Count -O--CK 100 100 020 - 966\n184 End-to-End_Error -O--CK 100 100 099 - 0\n187 Reported_Uncorrect -O--CK 100 100 000 - 0\n188 Command_Timeout -O--CK 100 100 000 - 1\n189 High_Fly_Writes -O-RCK 100 100 000 - 0\n190 Airflow_Temperature_Cel -O---K 071 043 045 Past 29 (0 2 29 24 0)\n191 G-Sense_Error_Rate -O--CK 100 100 000 - 11\n192 Power-Off_Retract_Count -O--CK 100 100 000 - 164\n193 Load_Cycle_Count -O--CK 018 018 000 - 164806\n194 Temperature_Celsius -O---K 029 057 000 - 29 (0 19 0 0 0)\n195 Hardware_ECC_Recovered -O-RC- 119 099 000 - 206410160\n197 Current_Pending_Sector -O--C- 100 100 000 - 0\n198 Offline_Uncorrectable ----C- 100 100 000 - 0\n199 UDMA_CRC_Error_Count -OSRCK 200 200 000 - 0\n240 Head_Flying_Hours ------ 100 253 000 - 1103 (11 165 0)\n241 Total_LBAs_Written ------ 100 253 000 - 2988175193\n242 Total_LBAs_Read ------ 100 253 000 - 711974475\n254 Free_Fall_Sensor -O--CK 100 100 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" } ] output = read_smartctl.read_smartctl(filedir) assert output == expect
def extract_data(directory: str, has_dedicated_gpu: bool, gpu_in_cpu: bool, cleanup: bool, verbose: bool, unpack: bool = True): mobo = get_baseboard(directory + "/baseboard.txt") cpu = read_lscpu(directory + "/lscpu.txt") gpu = read_lspci_and_glxinfo(has_dedicated_gpu, directory + "/lspci.txt", directory + "/glxinfo.txt", verbose) if not has_dedicated_gpu: entries = extract_integrated_gpu_from_standalone(gpu) if gpu_in_cpu: if isinstance(cpu, list): # Multiple processors updated_cpus = [] for one_cpu in cpu: one_cpu = {**one_cpu, **entries} updated_cpus.append(one_cpu) cpu = updated_cpus del updated_cpus else: cpu = {**cpu, **entries} else: mobo = {**mobo, **entries} gpu = [] mobo = get_connectors(directory + "/connector.txt", mobo, verbose) mobo = get_net(directory + "/net.txt", mobo, verbose) chassis = get_chassis(directory + "/chassis.txt") dimms = read_decode_dimms(directory + "/dimms.txt", verbose) if chassis["motherboard-form-factor"] == "proprietary-laptop": psu = {"type": "external-psu"} else: psu = {"type": "psu"} disks = read_smartctl(directory) result = [] empty_dict = {} for component in (chassis, mobo, cpu, dimms, gpu, disks, psu): # return JSON ready for TARALLO if unpack: if isinstance(component, list): if component.__len__() == 0: result.append(empty_dict) continue for item in component: result.append(item) else: result.append(component) # return list of lists of dicts to use in extract_and_collect_data_from_generated_files() for long output else: if component.__len__() == 0: result.append(empty_dict) else: result.append(component) if cleanup: result = do_cleanup(result, verbose) return result
def test_smartctl(): expect = [{ 'type': 'ssd', 'brand': 'Apple', 'family': 'SD/SM/TS...E/F/G SSDs', 'model': 'SM0512F', 'sn': 'S1K5NYCF740776', 'capacity-byte': 500000000000, 'wwn': '5 002538 655584d30', 'smart-data': 'ok', 'sata-ports-n': 1, 'notes': 'Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate -O-RC- 200 200 000 - 0\n 5 Reallocated_Sector_Ct PO--CK 100 100 000 - 0\n 9 Power_On_Hours -O--CK 097 097 000 - 10399\n 12 Power_Cycle_Count -O--CK 087 087 000 - 12802\n169 Unknown_Apple_Attrib PO--C- 253 253 010 - 3312107658752\n173 Wear_Leveling_Count -O--CK 186 186 100 - 584144191767\n174 Host_Reads_MiB -O---K 099 099 000 - 49185503\n175 Host_Writes_MiB -O---K 099 099 000 - 39494747\n192 Power-Off_Retract_Count -O--C- 099 099 000 - 254\n194 Temperature_Celsius -O---K 068 068 000 - 32 (Min/Max 8/75)\n197 Current_Pending_Sector -O---K 100 100 000 - 0\n199 UDMA_CRC_Error_Count -O-RC- 200 199 000 - 0\n240 Unknown_SSD_Attribute -O---K 100 100 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning' }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [{ "type": "hdd", "brand": "Toshiba", "model": "MQ01ABF050", "family": "2.5\" HDD MQ01ABF...", "sn": "76H3EUCL", "sata-ports-n": 1, "wwn": "5 000039 7222954ce", 'capacity-decibyte': 500000000000, 'spin-rate-rpm': 5400, 'smart-data': 'ok', 'hdd-form-factor': '2.5-7mm', 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate PO-R-- 100 100 050 - 0\n 2 Throughput_Performance P-S--- 100 100 050 - 0\n 3 Spin_Up_Time POS--K 100 100 001 - 1268\n 4 Start_Stop_Count -O--CK 100 100 000 - 9310\n 5 Reallocated_Sector_Ct PO--CK 100 100 050 - 0\n 7 Seek_Error_Rate PO-R-- 100 100 050 - 0\n 8 Seek_Time_Performance P-S--- 100 100 050 - 0\n 9 Power_On_Hours -O--CK 091 091 000 - 3990\n 10 Spin_Retry_Count PO--CK 253 100 030 - 0\n 12 Power_Cycle_Count -O--CK 100 100 000 - 3178\n191 G-Sense_Error_Rate -O--CK 100 100 000 - 1501\n192 Power-Off_Retract_Count -O--CK 100 100 000 - 62\n193 Load_Cycle_Count -O--CK 086 086 000 - 148398\n194 Temperature_Celsius -O---K 100 100 000 - 28 (Min/Max 13/44)\n196 Reallocated_Event_Count -O--CK 100 100 000 - 0\n197 Current_Pending_Sector -O--CK 100 100 000 - 0\n198 Offline_Uncorrectable ----CK 100 100 000 - 0\n199 UDMA_CRC_Error_Count -O--CK 200 200 000 - 2945\n220 Disk_Shift -O---- 100 100 000 - 0\n222 Loaded_Hours -O--CK 092 092 000 - 3421\n223 Load_Retry_Count -O--CK 100 100 000 - 0\n224 Load_Friction -O---K 100 100 000 - 0\n226 Load-in_Time -OS--K 100 100 000 - 197\n240 Head_Flying_Hours P----- 100 100 001 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [{ 'type': 'ssd', 'brand': 'LiteOn', 'model': 'CV1-8B128', # This is too much part of the model to extract 'family': '', 'sn': 'CV1-8B128_006923456A', 'wwn': '5 002303 234ddcce5', 'capacity-byte': 128000000000, 'human_readable_capacity': '128 GB', 'smart-data': 'ok', 'sata-ports-n': 1, # TODO: this is wrong, this is M.2 'notes': 'Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate POSR-K 100 100 000 - 0\n 5 Reallocated_Sector_Ct PO---- 100 100 000 - 0\n 9 Power_On_Hours -O---- 100 100 000 - 5\n 12 Power_Cycle_Count PO---- 100 100 000 - 1735\n170 Unknown_Attribute -O--CK 100 100 000 - 0\n171 Unknown_Attribute PO---- 100 100 000 - 0\n172 Unknown_Attribute PO---- 100 100 000 - 0\n173 Unknown_Attribute PO---- 100 100 000 - 22\n174 Unknown_Attribute PO---- 100 100 000 - 31\n175 Program_Fail_Count_Chip PO---- 100 100 000 - 0\n176 Erase_Fail_Count_Chip PO---- 100 100 000 - 0\n177 Wear_Leveling_Count PO---- 100 100 000 - 22\n178 Used_Rsvd_Blk_Cnt_Chip PO---- 100 100 000 - 0\n179 Used_Rsvd_Blk_Cnt_Tot PO---- 100 100 000 - 0\n180 Unused_Rsvd_Blk_Cnt_Tot PO--CK 100 100 000 - 143\n181 Program_Fail_Cnt_Total PO---- 100 100 000 - 0\n182 Erase_Fail_Count_Total PO---- 100 100 000 - 0\n183 Runtime_Bad_Block -O--CK 100 100 000 - 0\n189 Unknown_SSD_Attribute ------ 100 100 000 - 93\n191 Unknown_SSD_Attribute ------ 100 100 000 - 3\n192 Power-Off_Retract_Count PO---- 100 100 000 - 31\n194 Temperature_Celsius -O---- 100 100 000 - 45\n195 Hardware_ECC_Recovered PO---- 100 100 000 - 0\n199 UDMA_CRC_Error_Count PO---- 100 100 000 - 0\n232 Available_Reservd_Space PO---- 100 100 010 - 100\n233 Media_Wearout_Indicator PO---- 100 100 000 - 88140\n241 Total_LBAs_Written PO---- 100 100 000 - 69582\n242 Total_LBAs_Read PO---- 100 100 000 - 31505\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning' }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [ { "type": "hdd", "brand": "Western Digital", "model": "WD5002ABYS-02B1B0", "family": "RE3 Serial ATA", "wwn": "5 0014ee 7bf4d152d", "sn": "WCASYD636342", "capacity-decibyte": 500000000000, "human_readable_capacity": "500 GB", "spin-rate-rpm": 7200, "smart-data": "ok", 'sata-ports-n': 1, 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate POSR-K 200 200 051 - 0\n 3 Spin_Up_Time POS--K 239 230 021 - 1016\n 4 Start_Stop_Count -O--CK 100 100 000 - 227\n 5 Reallocated_Sector_Ct PO--CK 200 200 140 - 0\n 7 Seek_Error_Rate -OSR-K 200 200 000 - 0\n 9 Power_On_Hours -O--CK 035 035 000 - 47525\n 10 Spin_Retry_Count -O--CK 100 100 000 - 0\n 11 Calibration_Retry_Count -O--CK 100 100 000 - 0\n 12 Power_Cycle_Count -O--CK 100 100 000 - 224\n192 Power-Off_Retract_Count -O--CK 200 200 000 - 72\n193 Load_Cycle_Count -O--CK 200 200 000 - 154\n194 Temperature_Celsius -O---K 116 104 000 - 31\n196 Reallocated_Event_Count -O--CK 200 200 000 - 0\n197 Current_Pending_Sector -O--CK 200 200 000 - 0\n198 Offline_Uncorrectable ----CK 200 200 000 - 0\n199 UDMA_CRC_Error_Count -O--CK 200 200 000 - 0\n200 Multi_Zone_Error_Rate ---R-- 200 200 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" }, { "type": "hdd", "brand": "Western Digital", "model": "WD5002ABYS-02B1B0", "family": "RE3 Serial ATA", "wwn": "5 0014ee 3ef215d89", "sn": "WCASYE636777", "capacity-decibyte": 500000000000, "human_readable_capacity": "500 GB", "spin-rate-rpm": 7200, "smart-data": "ok", 'sata-ports-n': 1, 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate POSR-K 200 200 051 - 0\n 3 Spin_Up_Time POS--K 239 228 021 - 1033\n 4 Start_Stop_Count -O--CK 100 100 000 - 228\n 5 Reallocated_Sector_Ct PO--CK 200 200 140 - 0\n 7 Seek_Error_Rate -OSR-K 200 200 000 - 0\n 9 Power_On_Hours -O--CK 044 044 000 - 41574\n 10 Spin_Retry_Count -O--CK 100 100 000 - 0\n 11 Calibration_Retry_Count -O--CK 100 100 000 - 0\n 12 Power_Cycle_Count -O--CK 100 100 000 - 224\n192 Power-Off_Retract_Count -O--CK 200 200 000 - 72\n193 Load_Cycle_Count -O--CK 200 200 000 - 155\n194 Temperature_Celsius -O---K 116 105 000 - 31\n196 Reallocated_Event_Count -O--CK 200 200 000 - 0\n197 Current_Pending_Sector -O--CK 200 200 000 - 0\n198 Offline_Uncorrectable ----CK 200 200 000 - 0\n199 UDMA_CRC_Error_Count -O--CK 200 200 000 - 0\n200 Multi_Zone_Error_Rate ---R-- 200 200 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" } ] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [{ "type": "hdd", "brand": "Maxtor", "model": "6V080E0", "family": "DiamondMax 10 (SATA/300)", "sn": "V66666BG", "sata-ports-n": 1, "wwn": "0 150500 2ae42de3c", "spin-rate-rpm": -1, "capacity-decibyte": 82000000000, "human_readable_capacity": "81.9 GB", "smart-data": "ok", 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 3 Spin_Up_Time POS--K 224 224 063 - 10393\n 4 Start_Stop_Count -O--CK 253 253 000 - 591\n 5 Reallocated_Sector_Ct PO--CK 253 253 063 - 0\n 7 Seek_Error_Rate -O-R-- 251 241 000 - 4\n 8 Seek_Time_Performance POS--K 244 241 187 - 46094\n 9 Power_On_Hours -O--CK 248 248 000 - 2002\n 10 Spin_Retry_Count PO-R-K 253 252 157 - 0\n 11 Calibration_Retry_Count PO-R-K 253 252 223 - 0\n 12 Power_Cycle_Count -O--CK 252 252 000 - 597\n189 High_Fly_Writes -O-RCK 100 100 000 - 0\n190 Airflow_Temperature_Cel -O---K 067 052 000 - 33 (Min/Max 28/33)\n192 Power-Off_Retract_Count -O--CK 253 253 000 - 0\n193 Load_Cycle_Count -O--CK 253 253 000 - 0\n194 Temperature_Celsius -O--CK 038 253 000 - 33\n195 Hardware_ECC_Recovered -O-R-- 253 252 000 - 1026\n196 Reallocated_Event_Count ---R-- 253 253 000 - 0\n197 Current_Pending_Sector ---R-- 253 253 000 - 0\n198 Offline_Uncorrectable ---R-- 253 253 000 - 0\n199 UDMA_CRC_Error_Count ---R-- 199 199 000 - 0\n200 Multi_Zone_Error_Rate -O-R-- 253 252 000 - 0\n201 Soft_Read_Error_Rate -O-R-- 253 252 000 - 2\n202 Data_Address_Mark_Errs -O-R-- 253 252 000 - 0\n203 Run_Out_Cancel PO-R-- 253 252 180 - 0\n204 Soft_ECC_Correction -O-R-- 253 252 000 - 0\n205 Thermal_Asperity_Rate -O-R-- 253 252 000 - 0\n207 Spin_High_Current -O-R-K 253 252 000 - 0\n208 Spin_Buzz -O-R-K 253 252 000 - 0\n210 Unknown_Attribute -O--CK 253 252 000 - 0\n211 Unknown_Attribute -O--CK 253 252 000 - 0\n212 Unknown_Attribute -O--CK 253 252 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [{ "type": "hdd", "brand": "Hitachi", "model": "HDT725025VLA380", "family": "Deskstar T7K500", "wwn": "5 000cca 6904de32c", "sn": "VFA100R24D8ELK", "capacity-decibyte": 250000000000, "human_readable_capacity": "250 GB", "spin-rate-rpm": -1, "smart-data": "ok", 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate PO-R-- 100 100 016 - 0\n 2 Throughput_Performance P-S--- 100 100 050 - 0\n 3 Spin_Up_Time POS--- 115 115 024 - 330 (Average 321)\n 4 Start_Stop_Count -O--C- 100 100 000 - 89\n 5 Reallocated_Sector_Ct PO--CK 100 100 005 - 4\n 7 Seek_Error_Rate PO-R-- 100 100 067 - 0\n 8 Seek_Time_Performance P-S--- 100 100 020 - 0\n 9 Power_On_Hours -O--C- 090 090 000 - 74780\n 10 Spin_Retry_Count PO--C- 100 100 060 - 0\n 12 Power_Cycle_Count -O--CK 100 100 000 - 89\n192 Power-Off_Retract_Count -O--CK 098 098 000 - 3201\n193 Load_Cycle_Count -O--C- 098 098 000 - 3201\n194 Temperature_Celsius -O---- 176 176 000 - 34 (Min/Max 14/56)\n196 Reallocated_Event_Count -O--CK 100 100 000 - 4\n197 Current_Pending_Sector -O---K 100 100 000 - 0\n198 Offline_Uncorrectable ---R-- 100 100 000 - 0\n199 UDMA_CRC_Error_Count -O-R-- 200 253 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [{ "type": "hdd", "brand": "Maxtor", "model": "6Y080L0", "family": "DiamondMax Plus 9", "wwn": "", "sn": "Y2E5CRAE", "capacity-decibyte": 82000000000, "human_readable_capacity": "81,9 GB", "spin-rate-rpm": -1, "smart-data": "ok", 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 3 Spin_Up_Time POS--K 194 157 063 - 21293\n 4 Start_Stop_Count -O--CK 253 253 000 - 1539\n 5 Reallocated_Sector_Ct PO--CK 253 253 063 - 3\n 6 Read_Channel_Margin P----- 253 253 100 - 0\n 7 Seek_Error_Rate -O-R-- 253 252 000 - 0\n 8 Seek_Time_Performance POS--K 253 244 187 - 44709\n 9 Power_On_Minutes -O--CK 124 124 000 - 1009h+15m\n 10 Spin_Retry_Count PO-R-K 251 232 157 - 2\n 11 Calibration_Retry_Count PO-R-K 253 252 223 - 0\n 12 Power_Cycle_Count -O--CK 251 251 000 - 1169\n192 Power-Off_Retract_Count -O--CK 253 253 000 - 0\n193 Load_Cycle_Count -O--CK 253 253 000 - 0\n194 Temperature_Celsius -O--CK 253 253 000 - 36\n195 Hardware_ECC_Recovered -O-R-- 253 252 000 - 614\n196 Reallocated_Event_Count ---R-- 250 250 000 - 3\n197 Current_Pending_Sector ---R-- 253 253 000 - 0\n198 Offline_Uncorrectable ---R-- 153 153 000 - 100\n199 UDMA_CRC_Error_Count ---R-- 198 196 000 - 3\n200 Multi_Zone_Error_Rate -O-R-- 253 252 000 - 0\n201 Soft_Read_Error_Rate -O-R-- 253 236 000 - 186\n202 Data_Address_Mark_Errs -O-R-- 253 251 000 - 0\n203 Run_Out_Cancel PO-R-- 253 252 180 - 11\n204 Soft_ECC_Correction -O-R-- 253 252 000 - 0\n205 Thermal_Asperity_Rate -O-R-- 253 252 000 - 0\n207 Spin_High_Current -O-R-K 251 232 000 - 2\n208 Spin_Buzz -O-R-K 253 252 000 - 0\n209 Offline_Seek_Performnce --S--K 201 200 000 - 0\n 99 Unknown_Attribute --S--- 253 253 000 - 0\n100 Unknown_Attribute --S--- 253 253 000 - 0\n101 Unknown_Attribute --S--- 253 253 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning" }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [ { 'type': 'ssd', 'brand': 'Samsung', 'family': 'based SSDs', # whatever. 'model': '840 EVO 120GB', 'sn': 'S1F00F00F00F00', 'wwn': '5 002538 2c302d451', 'capacity-byte': 120000000000, 'human_readable_capacity': '120 GB', 'smart-data': 'ok', 'sata-ports-n': 1, 'notes': 'Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 5 Reallocated_Sector_Ct PO--CK 100 100 010 - 0\n 9 Power_On_Hours -O--CK 097 097 000 - 12337\n 12 Power_Cycle_Count -O--CK 095 095 000 - 4108\n177 Wear_Leveling_Count PO--C- 095 095 000 - 57\n179 Used_Rsvd_Blk_Cnt_Tot PO--C- 100 100 010 - 0\n181 Program_Fail_Cnt_Total -O--CK 100 100 010 - 0\n182 Erase_Fail_Count_Total -O--CK 100 100 010 - 0\n183 Runtime_Bad_Block PO--C- 100 100 010 - 0\n187 Uncorrectable_Error_Cnt -O--CK 100 100 000 - 0\n190 Airflow_Temperature_Cel -O--CK 072 058 000 - 28\n195 ECC_Error_Rate -O-RC- 200 200 000 - 0\n199 CRC_Error_Count -OSRCK 100 100 000 - 0\n235 POR_Recovery_Count -O--C- 099 099 000 - 133\n241 Total_LBAs_Written -O--CK 099 099 000 - 17500329386\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning' }, { 'type': 'hdd', 'brand': 'Western Digital', 'family': 'Black', 'model': 'WD1003FZEX-00MK2A0', 'wwn': '5 0014ee 21c4e201d', 'sn': 'WCC3B4RB4RB4R', 'capacity-decibyte': 1000000000000, 'human_readable_capacity': '1,00 TB', 'spin-rate-rpm': 7200, 'smart-data': 'ok', 'sata-ports-n': 1, 'notes': 'Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate POSR-K 200 200 051 - 0\n 3 Spin_Up_Time POS--K 176 174 021 - 2200\n 4 Start_Stop_Count -O--CK 094 094 000 - 6158\n 5 Reallocated_Sector_Ct PO--CK 200 200 140 - 0\n 7 Seek_Error_Rate -OSR-K 200 200 000 - 0\n 9 Power_On_Hours -O--CK 084 084 000 - 12016\n 10 Spin_Retry_Count -O--CK 100 100 000 - 0\n 11 Calibration_Retry_Count -O--CK 100 100 000 - 0\n 12 Power_Cycle_Count -O--CK 097 097 000 - 3965\n192 Power-Off_Retract_Count -O--CK 200 200 000 - 71\n193 Load_Cycle_Count -O--CK 198 198 000 - 6086\n194 Temperature_Celsius -O---K 115 106 000 - 28\n196 Reallocated_Event_Count -O--CK 200 200 000 - 0\n197 Current_Pending_Sector -O--CK 200 200 000 - 0\n198 Offline_Uncorrectable ----CK 100 253 000 - 0\n199 UDMA_CRC_Error_Count -O--CK 200 200 000 - 0\n200 Multi_Zone_Error_Rate ---R-- 100 253 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning' }, ] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): # RAID managed by motherboard expect = [{ "type": "hdd", "brand": "", "model": "", "family": "", "wwn": "", "sn": "", "capacity-decibyte": 996000000000, "spin-rate-rpm": 20000, "smart-data": None, }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): # TODO: parse this thing expect = [ { "type": "hdd", # Weird smarctl results here... there's no way in the file to tell this is a SSD and not an HDD "brand": "Samsung", "model": "MZFLV128HCGR-000MV", "family": "", "sn": "S244NX0H985438", "capacity-decibyte": -1, # This is also wrong because whatever "spin-rate-rpm": -1, "wwn": "", "notes": "SMART/Health Information (NVMe Log 0x02, NSID 0x1)\nCritical Warning: 0x00\nTemperature: 31 Celsius\nAvailable Spare: 100%\nAvailable Spare Threshold: 10%\nPercentage Used: 1%\nData Units Read: 9,622,050 [4.92 TB]\nData Units Written: 6,340,481 [3.24 TB]\nHost Read Commands: 128,200,306\nHost Write Commands: 69,116,853\nController Busy Time: 1,045\nPower Cycles: 692\nPower On Hours: 301\nUnsafe Shutdowns: 31\nMedia and Data Integrity Errors: 0\nError Information Log Entries: 0", "smart-data": "ok", } ] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): expect = [{ "type": "hdd", "brand": "Fujitsu", "model": "MJA2160BH G2", "family": "MJA BH", "wwn": "5 00000e 0447dfa8d", "sn": "K95BTA42BD8H", "capacity-decibyte": 160000000000, "spin-rate-rpm": 5400, "smart-data": "ok", 'sata-ports-n': 1, 'notes': "Vendor Specific SMART Attributes with Thresholds:\nID# ATTRIBUTE_NAME FLAGS VALUE WORST THRESH FAIL RAW_VALUE\n 1 Raw_Read_Error_Rate POSR-- 100 100 046 - 50270\n 2 Throughput_Performance P-S--- 100 100 030 - 25231360\n 3 Spin_Up_Time PO---- 100 100 025 - 0\n 4 Start_Stop_Count -O--CK 099 099 000 - 3215\n 5 Reallocated_Sector_Ct PO--CK 100 100 024 - 0 (2100 0)\n 7 Seek_Error_Rate POSR-- 100 100 047 - 1565\n 8 Seek_Time_Performance P-S--- 100 100 019 - 0\n 9 Power_On_Hours -O--CK 088 088 000 - 6251\n 10 Spin_Retry_Count PO--C- 100 100 020 - 0\n 12 Power_Cycle_Count -O--CK 100 100 000 - 3007\n192 Power-Off_Retract_Count -O--CK 100 100 000 - 85\n193 Load_Cycle_Count -O--CK 100 100 000 - 19460\n194 Temperature_Celsius -O---K 100 100 000 - 33 (Min/Max 9/45)\n195 Hardware_ECC_Recovered -O-RC- 100 100 000 - 185\n196 Reallocated_Event_Count -O--CK 100 100 000 - 0 (0 15680)\n197 Current_Pending_Sector -O--C- 100 100 000 - 0\n198 Offline_Uncorrectable ----C- 100 100 000 - 0\n199 UDMA_CRC_Error_Count -OSRCK 200 253 000 - 1\n200 Multi_Zone_Error_Rate POSR-- 100 100 060 - 15690\n203 Run_Out_Cancel -O---- 100 100 000 - 1529060392964\n240 Head_Flying_Hours -OSRCK 200 200 000 - 0\n ||||||_ K auto-keep\n |||||__ C event count\n ||||___ R error rate\n |||____ S speed/performance\n ||_____ O updated online\n |______ P prefailure warning", "hdd-form-factor": "2.5-7mm" }] output = read_smartctl.read_smartctl(filedir) assert output == expect
def test_smartctl(): output = read_smartctl.read_smartctl(filedir) assert 0 == len(output)
def test_smartctl(): expect = [] output = read_smartctl.read_smartctl(filedir) assert output == expect
def extract_data(directory: str, has_dedicated_gpu: bool, gpu_in_cpu: bool, gui: bool, verbose: bool, unpack: bool = True): mobo = get_baseboard(directory + "/baseboard.txt") cpu = read_lscpu(directory + "/lscpu.txt") gpu = read_lspci_and_glxinfo(has_dedicated_gpu, directory + "/lspci.txt", directory + "/glxinfo.txt", verbose) if not has_dedicated_gpu: entries = extract_integrated_gpu_from_standalone(gpu) if gpu_in_cpu: if isinstance(cpu, list): # Multiple processors updated_cpus = [] for one_cpu in cpu: one_cpu = {**one_cpu, **entries} updated_cpus.append(one_cpu) cpu = updated_cpus del updated_cpus else: cpu = {**cpu, **entries} else: mobo = {**mobo, **entries} gpu = [] mobo = get_connectors(directory + "/connector.txt", mobo, verbose) mobo = get_net(directory + "/net.txt", mobo, verbose) chassis = get_chassis(directory + "/chassis.txt") dimms = read_decode_dimms(directory + "/dimms.txt", verbose) if chassis["motherboard-form-factor"] == "proprietary-laptop": psu = {"type": "external-psu"} else: psu = {"type": "psu"} disks = read_smartctl(directory) result = [] empty_dict = {} for component in (chassis, mobo, cpu, dimms, gpu, disks, psu): # return JSON ready for TARALLO if unpack: if isinstance(component, list): if len(component) == 0: result.append(empty_dict) continue for item in component: result.append(item) else: result.append(component) # return list of lists of dicts to use in extract_and_collect_data_from_generated_files() for long output else: if len(component) == 0: result.append(empty_dict) else: result.append(component) result = do_cleanup(result, gui, verbose) # check on case and mobo try: if (chassis['model'], chassis['brand'], chassis['variant']) == (mobo['brand'], mobo['model'], mobo['variant']): chassis.pop('model') except KeyError: pass # maybe there's a nicer way comparator = [] for comp in result: if isinstance(comp, list): comparator = comparator + comp else: comparator.append(comp) # avoid bad associations between items and products for comp1 in comparator: for comp2 in comparator: if is_product(comp1) and is_product( comp2) and comp1['type'] != comp2['type']: if (comp1['brand'], comp2['model']) == (comp2['brand'], comp2['model']): variant1 = comp1.pop('variant', '') variant2 = comp2.pop('variant', '') if variant1 == variant2: comp1['variant'] = variant1.rstrip().join( f"_{comp1['type']}") comp2['variant'] = variant2.rstrip().join( f"_{comp2['type']}") return result
def test_77_no_disks_disk_that_doesnt_exist(): expect = [] output = read_smartctl.read_smartctl(os.path.join(filedir)) assert output == expect