truenas / py-SMART

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

Smartmontools values are not get.(Debian) #65

Closed Nikolay-Gamzin closed 1 year ago

Nikolay-Gamzin commented 1 year ago

Describe the bug 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.

Raw outputs DeviceList()[0] <SAT device on /dev/sda mod:HS-SSD-C100 120G sn:30087840294> sda = DeviceList()[0] sda.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]

smartctl -d test /dev/sda smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-19-amd64] (local build) Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/sda: Device of type 'scsi' [SCSI] detected /dev/sda [SAT]: Device open changed type from 'scsi' to 'sat' /dev/sda [SAT]: Device of type 'sat' [ATA] opened

smartctl --scan-open /dev/sda -d sat # /dev/sda [SAT], ATA device

smartctl -a /dev/sda smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-19-amd64] (local build) Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION === Device Model: HS-SSD-C100 120G Serial Number: 30087840294 LU WWN Device Id: 5 000000 0000027b6 Firmware Version: SN11913 User Capacity: 120,034,123,776 bytes [120 GB] Sector Size: 512 bytes logical/physical Rotation Rate: Solid State Device Form Factor: 2.5 inches TRIM Command: Available, deterministic, zeroed Device is: Not in smartctl database [for details use: -P showall] ATA Version is: ACS-4 (minor revision not indicated) SATA Version is: SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Tue Apr 11 14:26:57 2023 MSK SMART support is: Available - device has SMART capability. SMART support is: Enabled

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

General SMART Values: Offline data collection status: (0x00) Offline data collection activity was never started. Auto Offline Data Collection: Disabled. Self-test execution status: ( 0) The previous self-test routine completed without error or no self-test has ever been run. Total time to complete Offline data collection: ( 33) seconds. Offline data collection capabilities: (0x7b) SMART execute Offline immediate. Auto Offline data collection on/off support. Suspend Offline collection upon new command. Offline surface scan supported. Self-test supported. Conveyance Self-test supported. Selective Self-test supported. SMART capabilities: (0x0003) Saves SMART data before entering power-saving mode. Supports SMART auto save timer. Error logging capability: (0x01) Error logging supported. General Purpose Logging supported. Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 85) minutes. Conveyance self-test routine recommended polling time: ( 2) minutes. SCT capabilities: (0x0031) SCT Status supported. SCT Feature Control supported. SCT Data Table supported.

SMART Attributes Data Structure revision number: 20 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 5 Reallocated_Sector_Ct 0x1300 100 100 050 Old_age Offline - 0 9 Power_On_Hours 0x1200 100 100 000 Old_age Offline - 133 12 Power_Cycle_Count 0x1200 100 100 000 Old_age Offline - 9 167 Unknown_Attribute 0x2200 100 100 000 Old_age Offline - 0 168 Unknown_Attribute 0x1200 100 100 000 Old_age Offline - 0 169 Unknown_Attribute 0x1300 100 100 010 Old_age Offline - 327690 171 Unknown_Attribute 0x3200 100 100 000 Old_age Offline - 0 172 Unknown_Attribute 0x3200 100 100 000 Old_age Offline - 0 173 Unknown_Attribute 0x1200 200 200 000 Old_age Offline - 4296605716 175 Program_Fail_Count_Chip 0x2200 100 100 010 Old_age Offline - 0 180 Unused_Rsvd_Blk_Cnt_Tot 0x3300 100 100 000 Old_age Offline - 121 187 Reported_Uncorrect 0x3200 100 000 000 Old_age Offline - 0 192 Power-Off_Retract_Count 0x1200 100 100 000 Old_age Offline - 9 194 Temperature_Celsius 0x2200 032 032 000 Old_age Offline - 32 (Min/Max 27/35) 206 Unknown_SSD_Attribute 0x3200 200 200 000 Old_age Offline - 1 207 Unknown_SSD_Attribute 0x3200 200 200 000 Old_age Offline - 25 208 Unknown_SSD_Attribute 0x3200 200 200 000 Old_age Offline - 20 209 Unknown_SSD_Attribute 0x3200 200 200 000 Old_age Offline - 1 210 Unknown_Attribute 0x3200 200 200 000 Old_age Offline - 10 211 Unknown_Attribute 0x3200 200 200 000 Old_age Offline - 7 231 Unknown_SSD_Attribute 0x2300 100 100 005 Old_age Offline - 0 233 Media_Wearout_Indicator 0x2300 100 100 000 Old_age Offline - 896 234 Unknown_Attribute 0x3200 100 100 005 Old_age Offline - 86959 241 Total_LBAs_Written 0x3200 100 100 000 Old_age Offline - 714 242 Total_LBAs_Read 0x3200 100 100 000 Old_age Offline - 19 245 Unknown_Attribute 0x3200 100 100 000 Old_age Offline - 0

SMART Error Log Version: 1 No Errors Logged

SMART Self-test log structure revision number 1 No self-tests have been logged. [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1 SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS 1 0 0 Not_testing 2 0 0 Not_testing 3 0 0 Not_testing 4 0 0 Not_testing 5 0 0 Not_testing Selective self-test flags (0x0): After scanning selected spans, do NOT read-scan remainder of disk. If Selective self-test is pending on power-up, resume after 0 minute delay. Environmental setup:

ralequi commented 1 year ago

Hi @Nikolay-Gamzin

Notice that your drive is handled as scsi instead of ata/sata: /dev/sda: Device of type 'scsi' [SCSI] detected

the field .attributes is only filled with ATA ATTRIBUTES.

I know it is a bit confusing and I'm working to provide a clearer way to get those attributes. For now it is what it is.

If you have the latest pystorcli version, the data you are searching for is under .diagnostics field. (that field is only filled with scsi data BTW).

Tell me if you find out any other issue or if I haven't fixed your problem. Thanks for your interest

ralequi commented 1 year ago

Duplicate of #48

Nikolay-Gamzin commented 1 year ago

@ralequi Hi. pySMART version 1.2.3 But the disk is an SSD and the utility shows it correctly sda.is_ssd True sda.interface 'sat' But diagnostics is empty sda.diags {'Reallocated_Sector_Ct': '-', 'Start_Stop_Spec': '-', 'Start_Stop_Cycles': '-', 'Start_Stop_Pct_Left': '-', 'Load_Cycle_Spec': '-', 'Load_Cycle_Count': '-', 'Load_Cycle_Pct_Left': '-', 'Power_On_Hours': '-', 'Life_Left': '-', 'Corrected_Reads': '-', 'Corrected_Writes': '-', 'Corrected_Verifies': '-', 'Uncorrected_Reads': '-', 'Uncorrected_Writes': '-', 'Uncorrected_Verifies': '-', 'Reads_GB': '-', 'Writes_GB': '-', 'Verifies_GB': '-', 'Reads_count': '-', 'Writes_count': '-', 'Verifies_count': '-', 'block_size': '512', 'Non-Medium_Errors': '-'}

ralequi commented 1 year ago

Sorry, miss read, let me check it further

ralequi commented 1 year ago

Ok, I can confirm there is a bug parsing the output of

smartctl -d test /dev/sda
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-19-amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, [www.smartmontools.org](http://www.smartmontools.org/)

/dev/sda: Device of type 'scsi' [SCSI] detected
/dev/sda [SAT]: Device open changed type from 'scsi' to 'sat'
/dev/sda [SAT]: Device of type 'sat' [ATA] opened

Which is something different from the classic

smartctl 7.2 2021-01-17 r5171 [x86_64-linux-5.13.4-200.fc34.x86_64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

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

(notice there is no "error" detecting the type on the second output but there is on the first one)

ralequi commented 1 year ago

Another issue with your output is the ATA attribute format

SMART Attributes Data Structure revision number: 20 should be SMART Attributes Data Structure revision number: 1

That means this version is unsupported by pysmart, let me check how easy is to parse...

ralequi commented 1 year ago

Hi @Nikolay-Gamzin

Please, checkout the develop branch and tell me if the issue is still there.

You can try running pip install git+https://github.com/truenas/py-SMART.git@develop

If everything looks OK, I might launch release 1.2.4.

Thanks for your contribution!

Nikolay-Gamzin commented 1 year ago

Hi @ralequi Everything seems to be working correctly, thanks for the work done sda.attributes [None, None, None, None, None, <SMART Attribute 'Reallocated_Sector_Ct' 100/50 raw:0>, None, None, None, <SMART Attribute 'Power_On_Hours' 100/0 raw:147>, None, None, <SMART Attribute 'Power_Cycle_Count' 100/0 raw:9>, 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, <SMART Attribute 'Unknown_Attribute' 100/0 raw:0>, <SMART Attribute 'Unknown_Attribute' 100/0 raw:0>, <SMART Attribute 'Unknown_Attribute' 100/10 raw:327690>, None, <SMART Attribute 'Unknown_Attribute' 100/0 raw:0>, <SMART Attribute 'Unknown_Attribute' 100/0 raw:0>, <SMART Attribute 'Unknown_Attribute' 200/0 raw:4296802326>, None, <SMART Attribute 'Program_Fail_Count_Chip' 100/10 raw:0>, None, None, None, None, <SMART Attribute 'Unused_Rsvd_Blk_Cnt_Tot' 100/0 raw:121>, None, None, None, None, None, None, <SMART Attribute 'Reported_Uncorrect' 100/0 raw:0>, None, None, None, None, <SMART Attribute 'Power-Off_Retract_Count' 100/0 raw:9>, None, <SMART Attribute 'Temperature_Celsius' 032/0 raw:32 (Min/Max 27/35)>, None, None, None, None, None, None, None, None, None, None, None, <SMART Attribute 'Unknown_SSD_Attribute' 200/0 raw:1>, <SMART Attribute 'Unknown_SSD_Attribute' 200/0 raw:28>, <SMART Attribute 'Unknown_SSD_Attribute' 200/0 raw:22>, <SMART Attribute 'Unknown_SSD_Attribute' 200/0 raw:1>, <SMART Attribute 'Unknown_Attribute' 200/0 raw:11>, <SMART Attribute 'Unknown_Attribute' 200/0 raw:7>, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, <SMART Attribute 'Unknown_SSD_Attribute' 100/5 raw:0>, None, <SMART Attribute 'Media_Wearout_Indicator' 100/0 raw:989>, <SMART Attribute 'Unknown_Attribute' 100/5 raw:96496>, None, None, None, None, None, None, <SMART Attribute 'Total_LBAs_Written' 100/0 raw:790>, <SMART Attribute 'Total_LBAs_Read' 100/0 raw:21>, None, None, <SMART Attribute 'Unknown_Attribute' 100/0 raw:0>, None, None, None, None, None, None, None, None, None, None]

sda.all_attributes() ID# ATTRIBUTE_NAME CUR WST THR TYPE UPDATED WHEN_FAIL RAW 5 Reallocated_Sector_Ct 100 100 50 Old_age Offline - 0 9 Power_On_Hours 100 100 0 Old_age Offline - 147 12 Power_Cycle_Count 100 100 0 Old_age Offline - 9 167 Unknown_Attribute 100 100 0 Old_age Offline - 0 168 Unknown_Attribute 100 100 0 Old_age Offline - 0 169 Unknown_Attribute 100 100 10 Old_age Offline - 327690 171 Unknown_Attribute 100 100 0 Old_age Offline - 0 172 Unknown_Attribute 100 100 0 Old_age Offline - 0 173 Unknown_Attribute 200 200 0 Old_age Offline - 4296802326 175 Program_Fail_Count_Chip 100 100 10 Old_age Offline - 0 180 Unused_Rsvd_Blk_Cnt_Tot 100 100 0 Old_age Offline - 121 187 Reported_Uncorrect 100 0 0 Old_age Offline - 0 192 Power-Off_Retract_Count 100 100 0 Old_age Offline - 9 194 Temperature_Celsius 032 32 0 Old_age Offline - 32 (Min/Max 27/35) 206 Unknown_SSD_Attribute 200 200 0 Old_age Offline - 1 207 Unknown_SSD_Attribute 200 200 0 Old_age Offline - 28 208 Unknown_SSD_Attribute 200 200 0 Old_age Offline - 22 209 Unknown_SSD_Attribute 200 200 0 Old_age Offline - 1 210 Unknown_Attribute 200 200 0 Old_age Offline - 11 211 Unknown_Attribute 200 200 0 Old_age Offline - 7 231 Unknown_SSD_Attribute 100 100 5 Old_age Offline - 0 233 Media_Wearout_Indicator 100 100 0 Old_age Offline - 989 234 Unknown_Attribute 100 100 5 Old_age Offline - 96496 241 Total_LBAs_Written 100 100 0 Old_age Offline - 790 242 Total_LBAs_Read 100 100 0 Old_age Offline - 21 245 Unknown_Attribute 100 100 0 Old_age Offline - 0 example

sda.attributes[9] <SMART Attribute 'Power_On_Hours' 100/0 raw:147> sda.attributes[233] <SMART Attribute 'Media_Wearout_Indicator' 100/0 raw:989> sda.attributes[234] <SMART Attribute 'Unknown_Attribute' 100/5 raw:96496>

ralequi commented 1 year ago

New release published! Thanks again :-)