truenas / py-SMART

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

Smartmontools values are not get. #48

Closed Prometheus-Hu closed 1 year ago

Prometheus-Hu commented 2 years ago

BEGIN


Hi Developer & Supporter

Have a nice day! But one thing bothered me. I need to write Python to help me monitor the S.M.A.R.T information on my SSD. I found the tools developed by your team on the Internet and configured them. it doesn't seem to get the value right. So I hope you can help me.

BR!

prometheus_hu@outlook.com


In fact, SmartMonTools can obtain hard disk information, But attributes of PySMART output "None".


PowerShell 7.2.6 Copyright (c) Microsoft Corporation.

https://aka.ms/powershell Type 'help' to get help.

PS C:\Users\localhost> smartctl -a sda smartctl 7.3 2022-02-28 r5338 [x86_64-w64-mingw32-w10-21H2] (sf-7.3-1) Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION === Model Number: WDS100T3X0C-00SJG0 Serial Number: 20093F800129 Firmware Version: 111110WD 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: 8215 NVMe Version: 1.3 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 8b46ac714d Local Time is: Tue Sep 13 02:58:50 2022 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 (0x0e): Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg Maximum Data Transfer Size: 128 Pages Warning Comp. Temp. Threshold: 84 Celsius Critical Comp. Temp. Threshold: 88 Celsius Namespace 1 Features (0x02): NA_Fields

Supported Power States St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat 0 + 6.00W - - 0 0 0 0 0 0 1 + 3.50W - - 1 1 1 1 0 0 2 + 3.00W - - 2 2 2 2 0 0 3 - 0.1000W - - 3 3 3 3 4000 10000 4 - 0.0025W - - 4 4 4 4 4000 40000

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: 25 Celsius Available Spare: 100% Available Spare Threshold: 10% Percentage Used: 0% Data Units Read: 19,748,256 [10.1 TB] Data Units Written: 24,274,331 [12.4 TB] Host Read Commands: 256,089,807 Host Write Commands: 207,232,645 Controller Busy Time: 495 Power Cycles: 506 Power On Hours: 2,608 Unsafe Shutdowns: 39 Media and Data Integrity Errors: 0 Error Information Log Entries: 260 Warning Comp. Temperature Time: 2 Critical Comp. Temperature Time: 0

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

PS C:\Users\localhost>


from pySMART import Device
sda = Device('/dev/sda')
print(sda.__dict__)

"C:\Python\Python Project\diskSMARTmonitor\venv\Scripts\python.exe" "C:/Python/Python Project/diskSMARTmonitor/main.py" {'abridged': False, 'smartctl': <pySMART.smartctl.Smartctl object at 0x00000241DBF99360>, 'name': 'sda', 'model': 'WDS100T3X0C-00SJG0', 'serial': '20093F800129', 'vendor': None, 'interface': 'nvme', '_capacity': '1.00 TB', 'firmware': '111110WD', 'smart_capable': True, 'smart_enabled': True, 'assessment': 'PASS', 'messages': [], 'is_ssd': False, 'rotation_rate': None, 'attributes': [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None], 'test_capabilities': {'offline': False, 'short': True, 'long': True, 'conveyance': False, 'selective': False}, 'tests': [], '_test_running': False, '_test_ECD': None, '_test_progress': None, 'diagnostics': <pySMART.diagnostics.Diagnostics object at 0x00000241DBE2ED40>, 'temperature': 25, 'temperatures': {}}


END

ralequi commented 2 years ago

Hi @Prometheus-Hu , I don't have much testcases on windows, and I need a bit more output to work with.

Could you please provide the output of the following commands?

smartctl -d test /dev/sda
smartctl -d nvme --all /dev/sda

Also, as you have tested with smartctl -a sda the following commands will be useful too:

smartctl --scan-open
smartctl -d test sda
smartctl -d nvme --all sda
ralequi commented 2 years ago

In the other hand, have you checked the object diagnostics ? The attributes matrix is an... obfuscated way to deal with old-ata attributes that are not present on scsi/nvme devices

Prometheus-Hu commented 2 years ago

Hi @ralequi Thank you for your attention to this issue.

about second feedback “In the other hand, have you checked the object diagnostics ?”, ......No. Please tell me the right object or code if you can. O(∩_∩)O

Here is the infomation you need.

FYI


PS C:\Users\localhost> smartctl -d test /dev/sda smartctl 7.3 2022-02-28 r5338 [x86_64-w64-mingw32-w10-21H2] (sf-7.3-1) Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/sda: Device of type 'nvme' [NVMe] detected /dev/sda: Device of type 'nvme' [NVMe] opened


PS C:\Users\localhost> smartctl -d nvme --all /dev/sda smartctl 7.3 2022-02-28 r5338 [x86_64-w64-mingw32-w10-21H2] (sf-7.3-1) Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION === Model Number: WDS100T3X0C-00SJG0 Serial Number: 20093F800129 Firmware Version: 111110WD 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: 8215 NVMe Version: 1.3 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 8b46ac714d Local Time is: Tue Sep 13 22:57:28 2022 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 (0x0e): Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg Maximum Data Transfer Size: 128 Pages Warning Comp. Temp. Threshold: 84 Celsius Critical Comp. Temp. Threshold: 88 Celsius Namespace 1 Features (0x02): NA_Fields

Supported Power States St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat 0 + 6.00W - - 0 0 0 0 0 0 1 + 3.50W - - 1 1 1 1 0 0 2 + 3.00W - - 2 2 2 2 0 0 3 - 0.1000W - - 3 3 3 3 4000 10000 4 - 0.0025W - - 4 4 4 4 4000 40000

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: 25 Celsius Available Spare: 100% Available Spare Threshold: 10% Percentage Used: 0% Data Units Read: 19,767,201 [10.1 TB] Data Units Written: 24,283,729 [12.4 TB] Host Read Commands: 256,329,848 Host Write Commands: 207,404,109 Controller Busy Time: 496 Power Cycles: 508 Power On Hours: 2,608 Unsafe Shutdowns: 39 Media and Data Integrity Errors: 0 Error Information Log Entries: 261 Warning Comp. Temperature Time: 2 Critical Comp. Temperature Time: 0

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


PS C:\Users\localhost> smartctl --scan-open /dev/sda -d nvme # /dev/sda, NVMe device


PS C:\Users\localhost> smartctl -d test sda smartctl 7.3 2022-02-28 r5338 [x86_64-w64-mingw32-w10-21H2] (sf-7.3-1) Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

sda: Device of type 'nvme' [NVMe] detected sda: Device of type 'nvme' [NVMe] opened


PS C:\Users\localhost> smartctl -d nvme --all sda smartctl 7.3 2022-02-28 r5338 [x86_64-w64-mingw32-w10-21H2] (sf-7.3-1) Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION === Model Number: WDS100T3X0C-00SJG0 Serial Number: 20093F800129 Firmware Version: 111110WD 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: 8215 NVMe Version: 1.3 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 8b46ac714d Local Time is: Tue Sep 13 22:59:47 2022 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 (0x0e): Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg Maximum Data Transfer Size: 128 Pages Warning Comp. Temp. Threshold: 84 Celsius Critical Comp. Temp. Threshold: 88 Celsius Namespace 1 Features (0x02): NA_Fields

Supported Power States St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat 0 + 6.00W - - 0 0 0 0 0 0 1 + 3.50W - - 1 1 1 1 0 0 2 + 3.00W - - 2 2 2 2 0 0 3 - 0.1000W - - 3 3 3 3 4000 10000 4 - 0.0025W - - 4 4 4 4 4000 40000

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: 25 Celsius Available Spare: 100% Available Spare Threshold: 10% Percentage Used: 0% Data Units Read: 19,767,249 [10.1 TB] Data Units Written: 24,283,768 [12.4 TB] Host Read Commands: 256,331,082 Host Write Commands: 207,405,294 Controller Busy Time: 496 Power Cycles: 508 Power On Hours: 2,608 Unsafe Shutdowns: 39 Media and Data Integrity Errors: 0 Error Information Log Entries: 261 Warning Comp. Temperature Time: 2 Critical Comp. Temperature Time: 0

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

ralequi commented 2 years ago

Hi Prometheus,

Most part of the NVME data is not being read/stored into pysmart structures.

I'm working on a patch to merge more of this data into the structures keeping as much as backwards compatibility as I could.

The structure diagnostics is under property "diagnostics", however, as it is (mostly) used for scsi attributes, it's empty.

I will update you here when there is more data ported into pysmart structures

ralequi commented 2 years ago

Thanks for your contributions @Prometheus-Hu ..

I've added a new field to device called if_attributes. It will store specific-iface data. For now just nvme data is stored. In the future, this will be just a handler and the device will show metrics almost transparent to the iface. (ata/scsi/nvme... or at least that's the idea).

Please, confirm me that field fixes your issues and you could get the info you need.

To install using pypi try: pip install git+https://github.com/truenas/py-SMART@develop

Prometheus-Hu commented 2 years ago

I'm so sorry for missing your email

My network environment does not allow me to install Git, I have no way to carry out the next test to give you feedback. I guess you have fixed this problem, I'll be watching to see you release an new version.

Thank you again for your contribution to this project. @ralequi

ralequi commented 1 year ago

Hi @Prometheus-Hu ! I've forgotten to notice you before. I've release version 1.2, please, check it out when you are able ;-)

ralequi commented 1 year ago

Ok, I'm considering this as done.

Thanks for your contrib!