diff --git a/main.go b/main.go index c5b138a..4257be0 100644 --- a/main.go +++ b/main.go @@ -69,7 +69,7 @@ func (i *SMARTctlManagerCollector) Collect(ch chan<- prometheus.Metric) { json := readData(i.logger, device) if json.Exists() { info.SetJSON(json) - smart := NewSMARTctl(i.logger, json, ch) + smart := NewSMARTctl(i.logger, json, ch, device) smart.Collect() } } diff --git a/smartctl.go b/smartctl.go index b136b8b..8db1793 100644 --- a/smartctl.go +++ b/smartctl.go @@ -55,7 +55,7 @@ func buildDeviceLabel(inputName string, inputType string) string { } // NewSMARTctl is smartctl constructor -func NewSMARTctl(logger *slog.Logger, json gjson.Result, ch chan<- prometheus.Metric) SMARTctl { +func NewSMARTctl(logger *slog.Logger, json gjson.Result, ch chan<- prometheus.Metric, device Device) SMARTctl { var model_name string if obj := json.Get("model_name"); obj.Exists() { model_name = obj.String() @@ -72,7 +72,7 @@ func NewSMARTctl(logger *slog.Logger, json gjson.Result, ch chan<- prometheus.Me json: json, logger: logger, device: SMARTDevice{ - device: buildDeviceLabel(json.Get("device.name").String(), json.Get("device.type").String()), + device: device.Label, serial: strings.TrimSpace(json.Get("serial_number").String()), family: strings.TrimSpace(GetStringIfExists(json, "model_family", "unknown")), model: strings.TrimSpace(model_name),