storage SAT: fix NVMe SMART counters showing 0 for power-on hours/read/write

nvme-cli emits large 64-bit counters as JSON-quoted strings on some
versions; the disk-report text generator only handled bare numbers and
{lo,hi} objects, so power_on_hours/data_units_read/data_units_written
etc. silently parsed as 0 while the structured collector path already
handled this correctly. Unify both paths on a single exported
JSONInt64/NVMeSmartLog/NVMeIDCtrl type in collector/storage.go instead
of keeping two independent nvme-cli JSON parsers in sync.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 11:58:37 +03:00
parent 11ea640626
commit 33bc275da2
5 changed files with 85 additions and 114 deletions
@@ -9,7 +9,7 @@ import (
// TestNVMeSmartLogUnmarshal verifies that nvme-cli JSON output (where most
// counters are quoted strings and field names differ from NVMe spec prose)
// is correctly parsed into nvmeSmartLog.
// is correctly parsed into NVMeSmartLog.
func TestNVMeSmartLogUnmarshal(t *testing.T) {
t.Parallel()
@@ -30,7 +30,7 @@ func TestNVMeSmartLogUnmarshal(t *testing.T) {
"media_errors": "0",
"num_err_log_entries": "0"
}`
var log nvmeSmartLog
var log NVMeSmartLog
if err := json.Unmarshal([]byte(raw), &log); err != nil {
t.Fatalf("json.Unmarshal failed: %v", err)
}