Skip to content

Commit e877540

Browse files
Frank Wettsteinfraenku
authored andcommitted
Fix 298 by reusing the label instead of taking it from the json of smartctl
Signed-off-by: Frank Wettstein <wettstein.frank@gmail.com>
1 parent 89c135d commit e877540

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (i *SMARTctlManagerCollector) Collect(ch chan<- prometheus.Metric) {
6969
json := readData(i.logger, device)
7070
if json.Exists() {
7171
info.SetJSON(json)
72-
smart := NewSMARTctl(i.logger, json, ch)
72+
smart := NewSMARTctl(i.logger, json, ch, device)
7373
smart.Collect()
7474
}
7575
}

smartctl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func buildDeviceLabel(inputName string, inputType string) string {
5555
}
5656

5757
// NewSMARTctl is smartctl constructor
58-
func NewSMARTctl(logger *slog.Logger, json gjson.Result, ch chan<- prometheus.Metric) SMARTctl {
58+
func NewSMARTctl(logger *slog.Logger, json gjson.Result, ch chan<- prometheus.Metric, device Device) SMARTctl {
5959
var model_name string
6060
if obj := json.Get("model_name"); obj.Exists() {
6161
model_name = obj.String()
@@ -72,7 +72,7 @@ func NewSMARTctl(logger *slog.Logger, json gjson.Result, ch chan<- prometheus.Me
7272
json: json,
7373
logger: logger,
7474
device: SMARTDevice{
75-
device: buildDeviceLabel(json.Get("device.name").String(), json.Get("device.type").String()),
75+
device: device.Label,
7676
serial: strings.TrimSpace(json.Get("serial_number").String()),
7777
family: strings.TrimSpace(GetStringIfExists(json, "model_family", "unknown")),
7878
model: strings.TrimSpace(model_name),

0 commit comments

Comments
 (0)