From b442301994298022888e26ec378d9c6a3a69fa1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Bj=C3=B6rklin?= Date: Mon, 9 Sep 2024 15:32:20 -0700 Subject: [PATCH] fix: allow configuring powermode check to work better with SSDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #91 Signed-off-by: Robin Björklin --- main.go | 3 +++ readjson.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 7f55518..cb44797 100644 --- a/main.go +++ b/main.go @@ -111,6 +111,9 @@ var ( smartctlFakeData = kingpin.Flag("smartctl.fake-data", "The device to monitor (repeatable)", ).Default("false").Hidden().Bool() + smartctlPowerModeCheck = kingpin.Flag("smartctl.powermode-check", + "Whether or not to check powermode before fetching data", + ).Default("standby").String() ) // scanDevices uses smartctl to gather the list of available devices. diff --git a/readjson.go b/readjson.go index 234bc85..7db0831 100644 --- a/readjson.go +++ b/readjson.go @@ -64,7 +64,7 @@ func readFakeSMARTctl(logger log.Logger, device Device) gjson.Result { // Get json from smartctl and parse it func readSMARTctl(logger log.Logger, device Device) (gjson.Result, bool) { start := time.Now() - out, err := exec.Command(*smartctlPath, "--json", "--info", "--health", "--attributes", "--tolerance=verypermissive", "--nocheck=standby", "--format=brief", "--log=error", "--device="+device.Type, device.Name).Output() + out, err := exec.Command(*smartctlPath, "--json", "--info", "--health", "--attributes", "--tolerance=verypermissive", "--nocheck="+*smartctlPowerModeCheck, "--format=brief", "--log=error", "--device="+device.Type, device.Name).Output() if err != nil { level.Warn(logger).Log("msg", "S.M.A.R.T. output reading", "err", err, "device", device.Info_Name) }