Skip to content

Commit eaa070f

Browse files
committed
v0.5.5.3: wake drives on first poll for SMART baseline
On agent startup, the first poll skips the -n standby flag so smartctl wakes all drives and reads full SMART data. This ensures every drive is registered with its serial-based ID immediately. Subsequent polls honor standby mode normally. Fixes drives being silently dropped when sleeping on first scan after agent startup. Ref: #18 (rolandg-reflow)
1 parent 7fe41df commit eaa070f

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to SMART Sniffer are documented here.
44

5+
## v0.5.5.3 -- 2026-04-25
6+
7+
Agent-only patch. No integration, installer, or config changes.
8+
9+
Fixes drives being silently dropped when sleeping on agent startup, reported by @rolandg-reflow in [#18](https://github.com/DAB-LABS/smart-sniffer/issues/18).
10+
11+
### Fixed
12+
- **Drives no longer vanish when sleeping on startup** -- the agent's first poll after starting now wakes all drives to collect a full SMART baseline (serial, model, attributes). This ensures every drive is registered with its stable serial-based ID immediately. Subsequent polls honor `standby_mode` normally -- sleeping drives are skipped and cached data is served. Previously, a drive that was asleep on the first poll was silently dropped from the API because there was no cached data to serve.
13+
514
## v0.5.5.2 -- 2026-04-25
615

716
Agent-only patch. No integration, installer, or config changes.

agent/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,10 +613,11 @@ func (dc *DriveCache) Refresh() {
613613
// sleeping drives. Fall back to --scan if --scan-open is unsupported.
614614
scanCmd := "--scan"
615615
dc.mu.Lock()
616+
isFirstPoll := dc.firstPoll
616617
if dc.firstPoll {
617618
scanCmd = "--scan-open"
618619
dc.firstPoll = false
619-
log.Println("first poll: using --scan-open for protocol detection")
620+
log.Println("first poll: using --scan-open for protocol detection, waking drives for SMART baseline")
620621
}
621622
dc.mu.Unlock()
622623

@@ -676,7 +677,7 @@ func (dc *DriveCache) Refresh() {
676677
var order []string
677678

678679
for _, dev := range scanResult.Devices {
679-
info, inStandby := dc.fetchDriveInfo(dev.Name, dev.Protocol)
680+
info, inStandby := dc.fetchDriveInfo(dev.Name, dev.Protocol, isFirstPoll)
680681
if inStandby {
681682
// Drive is sleeping -- serve last known data with standby flag.
682683
slug := makeDriveSlug("", dev.Name) // fallback slug from path
@@ -779,7 +780,7 @@ func runSmartctl(smartctlPath string, args []string) ([]byte, int, error) {
779780
// fetchDriveInfo calls smartctl -a --json on a single device and parses the
780781
// key fields we care about. Returns (info, inStandby). When inStandby is true,
781782
// the drive was sleeping and no SMART data was collected.
782-
func (dc *DriveCache) fetchDriveInfo(devicePath, protocol string) (DriveInfo, bool) {
783+
func (dc *DriveCache) fetchDriveInfo(devicePath, protocol string, skipStandby bool) (DriveInfo, bool) {
783784
// Check the protocol cache: if we have a confirmed working protocol for this
784785
// device (e.g. "sat" from a previous SAT fallback, or a device_override),
785786
// use it upfront instead of relying on the scan-reported protocol.
@@ -790,7 +791,7 @@ func (dc *DriveCache) fetchDriveInfo(devicePath, protocol string) (DriveInfo, bo
790791
dc.mu.RUnlock()
791792

792793
args := []string{"--json", "-a"}
793-
if dc.standbyMode != "never" {
794+
if dc.standbyMode != "never" && !skipStandby {
794795
args = append(args, "-n", dc.standbyMode)
795796
}
796797
if strings.EqualFold(protocol, "sat") {
@@ -814,7 +815,7 @@ func (dc *DriveCache) fetchDriveInfo(devicePath, protocol string) (DriveInfo, bo
814815
// mismatch on NAS HBAs where SATA drives present as SCSI.
815816
if code&0x07 != 0 && strings.EqualFold(protocol, "scsi") {
816817
satArgs := []string{"--json", "-a", "-d", "sat"}
817-
if dc.standbyMode != "never" {
818+
if dc.standbyMode != "never" && !skipStandby {
818819
satArgs = append(satArgs, "-n", dc.standbyMode)
819820
}
820821
satArgs = append(satArgs, devicePath)

0 commit comments

Comments
 (0)