mirror of
https://github.com/prometheus-community/smartctl_exporter.git
synced 2024-11-23 01:43:07 +01:00
fix: allow configuring powermode check to work better with SSDs
fixes #91 Signed-off-by: Robin Björklin <robin.bjorklin@gmail.com>
This commit is contained in:
parent
2cc2249821
commit
b442301994
2 changed files with 4 additions and 1 deletions
3
main.go
3
main.go
|
@ -111,6 +111,9 @@ var (
|
||||||
smartctlFakeData = kingpin.Flag("smartctl.fake-data",
|
smartctlFakeData = kingpin.Flag("smartctl.fake-data",
|
||||||
"The device to monitor (repeatable)",
|
"The device to monitor (repeatable)",
|
||||||
).Default("false").Hidden().Bool()
|
).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.
|
// scanDevices uses smartctl to gather the list of available devices.
|
||||||
|
|
|
@ -64,7 +64,7 @@ func readFakeSMARTctl(logger log.Logger, device Device) gjson.Result {
|
||||||
// Get json from smartctl and parse it
|
// Get json from smartctl and parse it
|
||||||
func readSMARTctl(logger log.Logger, device Device) (gjson.Result, bool) {
|
func readSMARTctl(logger log.Logger, device Device) (gjson.Result, bool) {
|
||||||
start := time.Now()
|
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 {
|
if err != nil {
|
||||||
level.Warn(logger).Log("msg", "S.M.A.R.T. output reading", "err", err, "device", device.Info_Name)
|
level.Warn(logger).Log("msg", "S.M.A.R.T. output reading", "err", err, "device", device.Info_Name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue