TkTech / smartie

Pure-python ATA/SATA/ATAPI/SCSI and disk enumeration library for Linux/Windows/OS X.
https://tkte.ch/smartie/
MIT License
9 stars 3 forks source link

smartie cli cannot support SAS Disk #8

Open jackeichen opened 1 year ago

jackeichen commented 1 year ago

I test smartie with SAS disk, here is my disk info:

[root@localhost ~]# smartctl -a /dev/sdb
smartctl 7.1 2020-04-05 r5049 [x86_64-linux-4.18.0-305.3.1.el8.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               XXXXXXX ( I hide information here)
Product:              MZILT1T9HBJRV3
Revision:             CN32
Compliance:           SPC-4
User Capacity:        1,920,383,410,176 bytes [1.92 TB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
LU is resource provisioned, LBPRZ=1
Rotation Rate:        Solid State Device
Form Factor:          2.5 inches
Logical Unit id:      XXXXXXX ( I hide information here)
Serial number:        XXXXXXX ( I hide information here)
Device type:          disk
Transport protocol:   SAS (SPL-3)
Local Time is:        Fri Sep  1 07:52:12 2023 EDT
SMART support is:     Available - device has SMART capability.
SMART support is:     Enabled
Temperature Warning:  Enabled

=== START OF READ SMART DATA SECTION ===
SMART Health Status: OK

Percentage used endurance indicator: 0%
Current Drive Temperature:     31 C
Drive Trip Temperature:        65 C

Manufactured in week 41 of year 2019
Accumulated start-stop cycles:  145
Specified load-unload count over device lifetime:  0
Accumulated load-unload cycles:  0
Elements in grown defect list: 0

Error counter log:
           Errors Corrected by           Total   Correction     Gigabytes    Total
               ECC          rereads/    errors   algorithm      processed    uncorrected
           fast | delayed   rewrites  corrected  invocations   [10^9 bytes]  errors
read:          0        0         0         0          0      44609.083           0
write:         0        0         0         0          0      80920.541           0
verify:        0        0         0         0          0          0.109           0

Non-medium error count:      828

SMART Self-test log
Num  Test              Status                 segment  LifeTime  LBA_first_err [SK ASC ASQ]
     Description                              number   (hours)
# 1  Background short  Completed                   -     819                 - [-   -    -]

Long (extended) Self-test duration: 3600 seconds [60.0 minutes]

Error occurs when use smartie details:

[root@localhost ~]# smartie details /dev/sdb
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/smartie/scsi/__init__.py", line 115, in identify
    sense = self.issue_command(Direction.FROM, command16, identity)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/smartie/scsi/linux.py", line 69, in issue_command
    return self.parse_sense(raw_sense.raw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/smartie/scsi/__init__.py", line 53, in parse_sense
    raise SenseError(sense.sense_key, sense=sense)
smartie.errors.SenseError: <SenseError(error_code=0x05, err='Illegal Request')>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/smartie", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/smartie/cli.py", line 130, in details_command
    details_table.add_row("Model Number", device.model)
                                          ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/smartie/scsi/__init__.py", line 133, in model
    identity, sense = self.identify()
                      ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/smartie/scsi/__init__.py", line 124, in identify
    sense = self.issue_command(Direction.FROM, command16, identity)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/smartie/scsi/linux.py", line 69, in issue_command
    return self.parse_sense(raw_sense.raw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/smartie/scsi/__init__.py", line 53, in parse_sense
    raise SenseError(sense.sense_key, sense=sense)
smartie.errors.SenseError: <SenseError(error_code=0x05, err='Illegal Request')>
TkTech commented 1 year ago

Thanks! I don't have any way to fix this except theoretically. I'm trying to see if I can mooch an old server with SAS drives for a bit.

jackeichen commented 1 year ago

SCSI(like SAS) doesn't support ATA commands, include Smart releated and identify command. The tempeture and some other attributes canbe read by scsi log sense command. Because smartie mix SCSI/ATA into SCSI device, I think it should be a significant change, so need the ownner to do the future-work.

This is an example, get the tempeture by pydiskcmd. The tempeture is in parameter_code=0 filed ->parameter_value byte offset=2(bellow is bytearray(b'\x00!')[1] = 33 ℃) :

# pyscsi log-sense /dev/sdb -p 0x0D
issuing log sense command
/dev/sdb:

Log Page Name : Temperature
page_code     : 13
subpage_code  : 0
spf           : 0
ds            : 0
page_length   : 12
Log Parameters:

  parameter_code  : 0
  ctrl_bit        : 3
  parameter_length: 2
  parameter_value : bytearray(b'\x00!')
  --------------------------------------------------
  parameter_code  : 1
  ctrl_bit        : 3
  parameter_length: 2
  parameter_value : bytearray(b'\x00A')
  --------------------------------------------------
jackeichen commented 1 year ago

Thanks! I don't have any way to fix this except theoretically. I'm trying to see if I can mooch an old server with SAS drives for a bit.

My server is always here, if you are hard to get a system, let's co-wrok to do it.