cron job parameters for "Run SMART Test (short)"

Started by Evert, November 05, 2025, 01:01:15 PM

Previous topic - Next topic
Hi everyone,

I know that this question has been asked and answered a few years ago, but it seems to be an issue again...

When I create a task without a parameter, the backend log shows:
message 4fc16907-8409-4951-b00e-2c2f0ac74da9 [smart test short] returned b'smartctl 7.5 2025-04-30 r5714 [FreeBSD 14.3-RELEASE-p4 amd64] (local build)\nCopyright (C) 2002-25, B'When I specify '/dev/nvme0' as parameter, the backend log shows:
message 566968b0-348b-4539-b3e6-ddbe77fdc092 [smart test short /dev/nvme0] returned b'smartctl 7.5 2025-04-30 r5714 [FreeBSD 14.3-RELEASE-p4 amd64] (local build)\nCopyright (C) 2002-25, B'
In neither case does the SMART test actually seem to run.
--
Regards,
   Evert

Hi Evert,

That's just

# /usr/local/sbin/smartctl -t short <whatever-smartctl-accepts>

There some finicky stuff with NVME drive names in FreeBSD that smart doesn't like.

Also, it seems to avoid using the /dev/ prefix:

% sysctl -n kern.disks | sed s:nda:nvme:g
nvme0

So "nvme0" may work for you too. Try the command line first to see and then change the cron parameter accordingly.


Cheers,
Franco

Hi Franco,

'sysctl -n kern.disks | sed s:nda:nvme:g' returned indeed 'nvme0', but when I specify that as parameter, I still get:

message 0c172160-7f3a-438a-89df-69bb5fb88471 [smart test short nvme0] returned b'smartctl 7.5 2025-04-30 r5714 [FreeBSD 14.3-RELEASE-p4 amd64] (local build)\nCopyright (C) 2002-25, B'

--
Regards,
   Evert

Try the command line first:

# /usr/local/sbin/smartctl -t short nvme0

That preamble from smartctl may just be normal. In most cases the cron jobs are not for gathering log data, just executing the necessary commands. Without a wrapper to check the script output it may not do much other than run the test and bury the result. Likely "working as designed" in this case.


Cheers,
Franco

Have you verified the status page under Services → SMART → Info (type: All) whether the tests actually ran? Take a look at the Self-test logs section in the output. Or directly from the console by running 'smartctl -a /dev/nvme0'. Keep in mind that SMART test results aren't logged in the backend, so you'll need to check them manually as mentioned above. They also can't be monitored directly from cron jobs; for that, you'll likely need to set up Monit or a similar monitoring tool.
In theory there is no difference between theory and practice. In practice there is.

November 05, 2025, 08:04:46 PM #5 Last Edit: November 05, 2025, 08:25:03 PM by Patrick M. Hausen
Quote from: franco on November 05, 2025, 05:48:15 PMWithout a wrapper to check the script output it may not do much other than run the test and bury the result. Likely "working as designed" in this case.

smartctl does not output the result of the test, anyway. The test runs from a couple of minutes (short) to a couple of hours (long). You need to explicitly ask for the test results with smartctl, later.

root@opnsense:~ # smartctl -t short /dev/nvme0
smartctl 7.5 2025-04-30 r5714 [FreeBSD 14.3-RELEASE-p4 amd64] (local build)
Copyright (C) 2002-25, Bruce Allen, Christian Franke, www.smartmontools.org

Self-test has begun (NSID 0xffffffff)
Use smartctl -X to abort test

Oh, and the full device path is mandatory ...

Then you can later collect the test results like this:

smartctl -x /dev/nvme0
smartctl 7.5 2025-04-30 r5714 [FreeBSD 14.3-RELEASE-p4 amd64] (local build)
Copyright (C) 2002-25, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number:                       TS256GMTE710T
[...]
Self-test Log (NVMe Log 0x06, NSID 0xffffffff)
Self-test status: No self-test in progress
Num  Test_Description  Status                       Power_on_Hours  Failing_LBA  NSID Seg SCT Code
 0   Short             Completed: failed segments            14095      1066432     1   7 0x2 0x81

So I seem to have a failing LBA. OK ... should get a replacement sooner or later, probably.

EDIT: a full read with dd confirms a faulty drive. Just ordered a replacement. zpool scrub shows no errors, but I hardly use any of the capacity of the drive. Seems to be a good idea ;-)

HTH,
Patrick
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Services -> Smart and/or the CLI confirm that the test indeed runs (parameter needs to be full device path) 

If the result of the test isn't output anywhere, what is the best way to get notified when things go awry?



Oh, and good luck with your disk, Patrick!  ;-)
--
Regards,
   Evert

Quote from: Evert on November 06, 2025, 12:57:32 PMIf the result of the test isn't output anywhere, what is the best way to get notified when things go awry?


Well, that's the harder part. AFAIK, there is no GUI option where you can configure this in an if-this-than-that way. You'll probably need to write a script that parses the output from 'smartctl -a' or '-x', and acts accordingly, and run that from cron or Monit.
In theory there is no difference between theory and practice. In practice there is.

November 06, 2025, 09:11:13 PM #8 Last Edit: November 06, 2025, 09:13:54 PM by Patrick M. Hausen
4
Quote from: Evert on November 06, 2025, 12:57:32 PMIf the result of the test isn't output anywhere, what is the best way to get notified when things go awry?

You can run a daily job reporting the SMART status to a tool named Scrutiny. If one of your also regularly scheduled SMART self tests fails, then Scrutiny will show your drive in bright red instead of green 🙂

See here for my HOWTO.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Quote from: Evert on November 06, 2025, 12:57:32 PMOh, and good luck with your disk, Patrick!  ;-)

All good now:

Self-test Log (NVMe Log 0x06, NSID 0xffffffff)
Self-test status: No self-test in progress
Num  Test_Description  Status                       Power_on_Hours  Failing_LBA  NSID Seg SCT Code
 0   Short             Completed without error                   0            -     -   -   -    -



I was lucky, though. I just happened to have some fresh thermal paste at home. I needed it when reassembling the appliance.

Did you try Scrutiny, yet?
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)