adding mechanism to override the smartctl commands used by scrutiny for device scanning, device identification and smart data retrieval.

adding tests for command overrides.

rename GetScanOverrides() to GetDeviceOverrides()

fixes #255
This commit is contained in:
Jason Kulatunga
2022-05-28 15:32:44 -07:00
parent 2533d8d34f
commit a53397210c
13 changed files with 332 additions and 124 deletions
+4 -3
View File
@@ -116,12 +116,13 @@ func (mc *MetricsCollector) Collect(deviceWWN string, deviceName string, deviceT
}
mc.logger.Infof("Collecting smartctl results for %s\n", deviceName)
args := []string{"-x", "-j"}
fullDeviceName := fmt.Sprintf("%s%s", detect.DevicePrefix(), deviceName)
args := strings.Split(mc.config.GetCommandMetricsSmartArgs(fullDeviceName), " ")
//only include the device type if its a non-standard one. In some cases ata drives are detected as scsi in docker, and metadata is lost.
if len(deviceType) > 0 && deviceType != "scsi" && deviceType != "ata" {
args = append(args, "-d", deviceType)
args = append(args, "--device", deviceType)
}
args = append(args, fmt.Sprintf("%s%s", detect.DevicePrefix(), deviceName))
args = append(args, fullDeviceName)
result, err := mc.shell.Command(mc.logger, "smartctl", args, "", os.Environ())
resultBytes := []byte(result)