@cryptotaxi247 / netdata-1 / commits / d46f4c992

chore(go.d/smartctl): debug log exec output (#20460)

Ilya Mashchenko committed Jun 10, 2025 at 14:32 UTC d46f4c9928c0708a1805d3a172536c8b57c16f3f
1 file changed +10
src/go/plugin/go.d/collector/smartctl/exec.go
+10
@@ -5,9 +5,12 @@
5 package smartctl
6
7 import (
8 + "bytes"
9 "context"
10 + "encoding/json"
11 "errors"
12 "fmt"
13 + "log/slog"
14 "os/exec"
15 "time"
16
@@ -68,6 +71,13 @@ func (e *smartctlCliExec) execute(args ...string) (*gjson.Result, error) {
71 return nil, fmt.Errorf("'%s' returned no output", cmd)
72 }
73
74 + if logger.Level.Enabled(slog.LevelDebug) {
75 + var buf bytes.Buffer
76 + if err := json.Compact(&buf, bs); err == nil {
77 + e.Debugf("exec: %v, resp: %s", args, buf.String())
78 + }
79 + }
80 +
81 if !gjson.ValidBytes(bs) {
82 return nil, fmt.Errorf("'%s' returned invalid JSON output", cmd)
83 }