retrieve smart results for disks using the API?

kfrank

Cadet
Joined
Mar 20, 2023
Messages
8
Is there anyway to retrieve the most recent smart results for disks using the API?
I would like to create a dashboard in home assistant that would show the health of each disk in the pool, not just the health of the pool itself.
Thank you for any help in advance.

I am currently using:
TrueNAS-SCALE-22.12.2 on a Dell R720xd with 16 cores and 32 threads
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
midclt call disk.smart_attributes sda | jq

That works from the shell... you can figure out the remote rest call syntax from that clue.
 

kfrank

Cadet
Joined
Mar 20, 2023
Messages
8
midclt call disk.smart_attributes sda | jq

That works from the shell... you can figure out the remote rest call syntax from that clue.
This is what I get when I run that from the shell:

Code:
admin@truenas:~$ midclt call disk.smart_attributes sdb | jq
[EFAULT] Only ATA device support S.M.A.R.T. attributes
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 196, in call_method
    result = await self.middleware._call(message['method'], serviceobj, methodobj, params, app=self)
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1335, in _call
    return await methodobj(*prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1318, in nf
    return await func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1186, in nf
    res = await f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/disk_/smart_attributes.py", line 46, in smart_attributes
    raise CallError('Only ATA device support S.M.A.R.T. attributes')
middlewared.service_exception.CallError: [EFAULT] Only ATA device support S.M.A.R.T. attributes
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Is sda a SATA/SAS disk?

Does it work on any other devices than sda?
 
Last edited:

kfrank

Cadet
Joined
Mar 20, 2023
Messages
8
Is sda a SATA/SAS disk?

Does it work on any other devices than sda?
I actually was able to retrieve the result of smart test using the api by running:

Code:
curl -X GET -H "Authorization: Bearer <API Key>" http://<trueNAS IP or host name>/api/v2.0/smart/test/results

the response include results such as the following for all of my disks:


Code:
 {
  "tests": [
   {
    "num": 1,
    "description": "Background short",
    "status_verbose": "Completed",
    "segment_number": 64,
    "lifetime": 2,
    "lba_of_first_error": null,
    "status": "SUCCESS"
   },
   {
    "num": 2,
    "description": "Reserved(7)",
    "status_verbose": "Completed",
    "segment_number": 48,
    "lifetime": 2,
    "lba_of_first_error": null,
    "status": "SUCCESS"
   },
   {
    "num": 3,
    "description": "Background short",
    "status_verbose": "Completed",
    "segment_number": 64,
    "lifetime": 1,
    "lba_of_first_error": null,
    "status": "SUCCESS"
   }
  ],
  "current_test": null,
  "identifier": "{serial_lunid}S0M34VW4_5000c500770100c3",
  "name": "sdd",
  "subsystem": "scsi",
  "number": 2096,
  "serial": "S0M34VW4",
  "lunid": "5000c500770100c3",
  "size": 600127266816,
  "description": "",
  "transfermode": "Auto",
  "hddstandby": "ALWAYS ON",
  "advpowermgmt": "DISABLED",
  "togglesmart": true,
  "smartoptions": "",
  "expiretime": null,
  "critical": null,
  "difference": null,
  "informational": null,
  "model": "ST600MM0006",
  "rotationrate": 10000,
  "type": "HDD",
  "zfs_guid": "16236018136366907121",
  "bus": "SCSI",
  "devname": "sdd",
  "enclosure": null,
  "supports_smart": null,
  "pool": null,
  "disk": "sdd"
 }
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Cool :cool:
 
Top