mirror of
https://github.com/prometheus-community/smartctl_exporter.git
synced 2024-12-21 02:21:55 +01:00
Accomodate a smartmontools pre-7.3 bug
https://www.smartmontools.org/changeset/5283 Signed-off-by: Nathan Carlson <carl4403@umn.edu>
This commit is contained in:
parent
2cc2249821
commit
eef6f880a8
2 changed files with 5 additions and 1 deletions
|
@ -54,6 +54,8 @@ for device in "${devices[@]}"
|
||||||
echo -n "Collecting data for '${device}'..."
|
echo -n "Collecting data for '${device}'..."
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
data="$($SUDO smartctl ${smartctl_args} ${device})"
|
data="$($SUDO smartctl ${smartctl_args} ${device})"
|
||||||
|
# Accomodate a smartmontools pre-7.3 bug
|
||||||
|
data=${data#" Pending defect count:"}
|
||||||
type="$(echo "${data}" | "${json_tool}" "${json_args}" '.device.type')"
|
type="$(echo "${data}" | "${json_tool}" "${json_args}" '.device.type')"
|
||||||
family="$(echo "${data}" | "${json_tool}" "${json_args}" \
|
family="$(echo "${data}" | "${json_tool}" "${json_args}" \
|
||||||
'select(.model_family != null) | .model_family | sub(" |/" ; "_" ; "g")
|
'select(.model_family != null) | .model_family | sub(" |/" ; "_" ; "g")
|
||||||
|
|
|
@ -68,7 +68,9 @@ func readSMARTctl(logger log.Logger, device Device) (gjson.Result, bool) {
|
||||||
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)
|
||||||
}
|
}
|
||||||
json := parseJSON(string(out))
|
// Accomodate a smartmontools pre-7.3 bug
|
||||||
|
cleaned_out := strings.TrimPrefix(string(out), " Pending defect count:")
|
||||||
|
json := parseJSON(cleaned_out)
|
||||||
rcOk := resultCodeIsOk(logger, device, json.Get("smartctl.exit_status").Int())
|
rcOk := resultCodeIsOk(logger, device, json.Get("smartctl.exit_status").Int())
|
||||||
jsonOk := jsonIsOk(logger, json)
|
jsonOk := jsonIsOk(logger, json)
|
||||||
level.Debug(logger).Log("msg", "Collected S.M.A.R.T. json data", "device", device.Info_Name, "duration", time.Since(start))
|
level.Debug(logger).Log("msg", "Collected S.M.A.R.T. json data", "device", device.Info_Name, "duration", time.Since(start))
|
||||||
|
|
Loading…
Reference in a new issue