truenas / py-SMART

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

Device init for virtual drives or no smart support #74

Closed ulmitov closed 7 months ago

ulmitov commented 1 year ago

Hi! A minor improvement request for virtual drives or drves that have "SMART support is: Unavailable", To skip sending of "smartctl -d scsi -l background /dev/sda" command

# smartctl -x /dev/sda
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-5.15.0-25-generic] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               AVAGO
Product:              MR9361-16i
Revision:             4.72
Compliance:           SPC-3
User Capacity:        959,119,884,288 bytes [959 GB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
Logical Unit id:      0x600062b2079c34000000f253f50d4c57
Serial number:        00574c0df553f2000000349c07b26200
Device type:          disk
Local Time is:        Wed Aug 30 12:39:17 2023 MSK
SMART support is:     Unavailable - device lacks SMART capability.
Read Cache is:        Enabled
Writeback Cache is:   Disabled

=== START OF READ SMART DATA SECTION ===
Current Drive Temperature:     0 C
Drive Trip Temperature:        0 C

Error Counter logging not supported

Device does not support Self Test logging
Device does not support Background scan results logging
ralequi commented 1 year ago

Hi!

The usually initial command is smartctl -d test /dev/sda Could you copy that output to complete the test-case?

Thank you!

ulmitov commented 1 year ago
In [1]: import pySMART as ps

# prints of all generic_calls:
In [2]: d=ps.DeviceList()
['/usr/local/sbin/smartctl', '--scan-open']
['/usr/local/sbin/smartctl', '-d', 'scsi', '--all', '/dev/sda']
['/usr/local/sbin/smartctl', '-d', 'scsi', '-l', 'background', '/dev/sda']
['/usr/local/sbin/smartctl', '-d', 'scsi', '--all', '/dev/sdb']
['/usr/local/sbin/smartctl', '-d', 'scsi', '-l', 'background', '/dev/sdb']
['/usr/local/sbin/smartctl', '-d', 'scsi', '--all', '/dev/sdc']
['/usr/local/sbin/smartctl', '-d', 'scsi', '-l', 'background', '/dev/sdc']
['/usr/local/sbin/smartctl', '-d', 'sat+megaraid,23', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,38', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,39', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,42', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,43', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,44', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,45', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,47', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,48', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'sat+megaraid,49', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'sat+megaraid,50', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'sat+megaraid,51', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,53', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,55', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,56', '--all', '/dev/bus/0']
['/usr/local/sbin/smartctl', '-d', 'megaraid,57', '--all', '/dev/bus/0']

In [3]: !smartctl -d test /dev/sda
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-5.15.0-25-generic] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/sda: Device of type 'scsi' [SCSI] detected
/dev/sda: Device of type 'scsi' [SCSI] opened

In [4]: !smartctl -x /dev/sda
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-5.15.0-25-generic] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               AVAGO
Product:              MR9361-16i
Revision:             4.72
Compliance:           SPC-3
User Capacity:        959,119,884,288 bytes [959 GB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
Logical Unit id:      0x600062b2079c34000000f253f50d4c57
Serial number:        00574c0df553f2000000349c07b26200
Device type:          disk
Local Time is:        Wed Aug 30 14:19:21 2023 MSK
SMART support is:     Unavailable - device lacks SMART capability.
Read Cache is:        Enabled
Writeback Cache is:   Disabled

=== START OF READ SMART DATA SECTION ===
Current Drive Temperature:     0 C
Drive Trip Temperature:        0 C

Error Counter logging not supported

Device does not support Self Test logging
Device does not support Background scan results logging
ralequi commented 1 year ago

Thank you @ulmitov I think with the previous commit this should be fixed.

ralequi commented 7 months ago

I suppose this is already fixed.

Feel free to re-open if not @ulmitov