scrutiny: [Standby-Support][BUG] Disks in standby mode are not correctly processed/detected - Scrutiny will create a duplicate disk with empty data
Describe the bug
I installed scrutiny through the linuxserver docker container on a raspberry pi 4 to which I have attached two disks by USB connection. When running for the first time scrutiny scrutiny-collector-metrics run
command, my two hard disk are recognized. One is a hdd while another is a ssd. Thus, I have two entries on scrutiny (that is expected behaviour). However, I have noticed that after some time (like around a day) a new “empty” entry appears. I have marked it in red in the below screenshot. Do you know how to get rid of that fake entry?
Expected behavior Scrutiny should only list my two disks. It does it but also shows another entry of a “phantom” disk.
Screenshots
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 2
- Comments: 20 (8 by maintainers)
ahh ok. I just took a closer look at that non-zero exit code of
2
and it matchesbit 1
in the docs: http://www.linuxguide.it/command_line/linux-manpage/do.php?file=smartctl#sect7In general, scrutiny shouldn’t be forwarding empty, invalid data from the collector to the webapp, but we ignore non-zero exit codes because
bit 3
will be set whensmartctl
detects an error, and that response is valid, with real meaningful data.I’ll need to come up with a generic process to handle disks in standby mode or that haven’t been “seen” in a while – maybe just a new notification rule. Atleast I know what to look for now. Thanks for all the data everyone! 👍
Just to add to the logs and provide some suggestions. This is a sleeping external USB hard drive. The hard drive appeared to be too slow to respond to smartctl in its spin up
Suggestion 1: Include a quick read from the drive before running smartctl
# dd if=/dev/sda bs=1k count=1 of=/dev/zero
This will cause the drive to wake up ahead of running smartctl. This should be safe on all drives and will block scrutiny pending the read being successful.Suggestion 2: Include a probe of the drives before running smartctl
# partprobe -d /dev/sda
This should cause the drive to wake up.Suggestion 3: Work around It would appear that if smartctl returns that particular error, the app should sleep for 10 seconds and the command should simply be retried.
Recommendation I’d probably do one of the first two, as there is little downside in a quick read/probe prior to running smartctl. It would ensure it always has a live drive to read from.
Additional Enhancement Irrespective, it should also maybe not add the drive to the dashboard if the drive wasn’t detected properly.
Logs showing one sleeping drive (sdc)
As a workaround while waiting for a fix, I added a cron job to wake the disk up (
ls /mounted/path
) a minute before midnight when the collector task is scheduled to kick in. On a fresh install, this seems to avoid the problem - no phantom disk has been detected after running it for 5 days. It does look like the problem is related to the disk entering sleep mode.