truenas / py-SMART

Wrapper for smartctl (smartmontools)
GNU Lesser General Public License v2.1
76 stars 35 forks source link

Nvme device: ValueError: invalid literal for int() with base 10 #52

Closed ulmitov closed 1 year ago

ulmitov commented 1 year ago

In [1]: import pySMART

In [3]: pySMART.SMARTCTL.sudo = True

In [4]: devlist = pySMART.DeviceList()

ValueError Traceback (most recent call last) Cell In [4], line 1 ----> 1 devlist = pySMART.DeviceList()

File ~/.local/lib/python3.10/site-packages/pySMART/device_list.py:63, in DeviceList.init(self, init, smartctl) 60 """The smartctl wrapper 61 """ 62 if init: ---> 63 self._initialize()

File ~/.local/lib/python3.10/site-packages/pySMART/device_list.py:110, in DeviceList._initialize(self) 107 name = groups[0] 108 interface = groups[1] 109 self.devices.append( --> 110 Device(name, interface=interface, smartctl=self.smartctl)) 112 # Remove duplicates and unwanted devices (optical, etc.) from the list 113 self._cleanup()

File ~/.local/lib/python3.10/site-packages/pySMART/device.py:283, in Device.init(self, name, interface, abridged, smart_options, smartctl) 280 # If a valid device was detected, populate its information 281 # OR if in unabridged mode, then do it even without interface info 282 if self.interface is not None or self.abridged: --> 283 self.update()

File ~/.local/lib/python3.10/site-packages/pySMART/device.py:853, in Device.update(self) 848 ####################################### 849 # Dedicated interface attributes # 850 ####################################### 852 if interface == 'nvme': --> 853 self.if_attributes = NvmeAttributes(iter(_stdout)) 854 else: 855 self.if_attributes = None

File ~/.local/lib/python3.10/site-packages/pySMART/interface/nvme.py:483, in NvmeAttributes.init(self, data) 480 self.errors: List[NvmeError] = [] 482 if data is not None: --> 483 self.parse(data)

File ~/.local/lib/python3.10/site-packages/pySMART/interface/nvme.py:526, in NvmeAttributes.parse(self, data) 523 self.percentageUsed = int(value[:-1]) 524 elif name == 'Data Units Read': 525 # Format: 1,234,567 [2.00 TB] --> 526 self.dataUnitsRead = int( 527 value.split(' ')[0].replace(',', '').replace('.', '')) 528 self.bytesRead = humanfriendly.parse_size( 529 value.split(' ', 1)[1][1:-1].replace(',', '.')) 530 elif name == 'Data Units Written': 531 # Format: 1,234,567 [2.00 TB]

ValueError: invalid literal for int() with base 10: '667\u202f413'

smartctl --scan-open /dev/nvme0 -d nvme # /dev/nvme0, NVMe device

sudo smartctl --info /dev/nvme0n1 smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.0-53-generic] (local build) Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION === Model Number: WDC WDS100T2B0C-00PXH0 Serial Number: 220312800929 Firmware Version: 233010WD PCI Vendor/Subsystem ID: 0x15b7 IEEE OUI Identifier: 0x001b44 Total NVM Capacity: 1 000 204 886 016 [1,00 TB] Unallocated NVM Capacity: 0 Controller ID: 0 NVMe Version: 1.4 Number of Namespaces: 1 Namespace 1 Size/Capacity: 1 000 204 886 016 [1,00 TB] Namespace 1 Formatted LBA Size: 512 Namespace 1 IEEE EUI-64: 001b44 8b45ea9cce

ralequi commented 1 year ago

The value Data Units Read is not present on the smartctl provided...

¡Second interesting issue of the day!

Please, provide the output as the last time: sudo smartctl --all /dev/nvme0n1

ulmitov commented 1 year ago

=== START OF INFORMATION SECTION === Model Number: WDC WDS100T2B0C-00PXH0 Serial Number: 220312800929 Firmware Version: 233010WD PCI Vendor/Subsystem ID: 0x15b7 IEEE OUI Identifier: 0x001b44 Total NVM Capacity: 1 000 204 886 016 [1,00 TB] Unallocated NVM Capacity: 0 Controller ID: 0 NVMe Version: 1.4 Number of Namespaces: 1 Namespace 1 Size/Capacity: 1 000 204 886 016 [1,00 TB] Namespace 1 Formatted LBA Size: 512 Namespace 1 IEEE EUI-64: 001b44 8b45ea9cce Local Time is: Wed Dec 7 16:58:55 2022 MSK Firmware Updates (0x14): 2 Slots, no Reset required Optional Admin Commands (0x0017): Security Format Frmw_DL Self_Test Optional NVM Commands (0x005f): Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat Timestmp Log Page Attributes (0x1e): Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg Pers_Ev_Lg Maximum Data Transfer Size: 128 Pages Warning Comp. Temp. Threshold: 80 Celsius Critical Comp. Temp. Threshold: 85 Celsius Namespace 1 Features (0x02): NA_Fields

Supported Power States St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat 0 + 3.50W 2.90W - 0 0 0 0 0 0 1 + 2.70W 2.30W - 0 0 0 0 0 0 2 + 1.90W 1.80W - 0 0 0 0 0 0 3 - 0.0250W - - 3 3 3 3 3900 11000 4 - 0.0050W - - 4 4 4 4 5000 44000

Supported LBA Sizes (NSID 0x1) Id Fmt Data Metadt Rel_Perf 0 + 512 0 2 1 - 4096 0 1

=== START OF SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED

SMART/Health Information (NVMe Log 0x02) Critical Warning: 0x00 Temperature: 34 Celsius Available Spare: 100% Available Spare Threshold: 10% Percentage Used: 0% Data Units Read: 667 420 [341 GB] Data Units Written: 852 433 [436 GB] Host Read Commands: 8 140 849 Host Write Commands: 16 154 207 Controller Busy Time: 83 Power Cycles: 43 Power On Hours: 31 Unsafe Shutdowns: 24 Media and Data Integrity Errors: 0 Error Information Log Entries: 2 Warning Comp. Temperature Time: 0 Critical Comp. Temperature Time: 0

Error Information (NVMe Log 0x01, 16 of 256 entries) No Errors Logged

ralequi commented 1 year ago

there should be something weird with your setup.

I suppose it should be related with lang/location, but not sure why.

The character that is returned by your smartctl should be just a comma ,.

I'm going to consider this as a corner case and support it... but I would appreciate if you can share the env variables or other conditions that may lead to this anomalous behaviour .

Thank you in advance

ralequi commented 1 year ago

Try the develop release (you can install using pip install git+https://github.com/truenas/py-SMART@develop) and tell me if it is fixed or not.

Add here any other utf8/encoding issues you found out there.

Thank you for your time.

ulmitov commented 1 year ago

@ralequi The develop release works! no other issues found

ralequi commented 1 year ago

I'm closing this issue then.

I would double-check this as it seems there is something strange on windows with this character. I'll try to fix it before merge the fix into master.

Thanks again!