Change logic to allow recording of device fields when attributes is false (#6638)
This commit is contained in:
parent
fc57012629
commit
1b4aad2ccd
|
@ -319,6 +319,7 @@ func gatherDisk(acc telegraf.Accumulator, timeout internal.Duration, usesudo, co
|
|||
|
||||
attr := attribute.FindStringSubmatch(line)
|
||||
if len(attr) > 1 {
|
||||
// attribute has been found, add it only if collectAttributes is true
|
||||
if collectAttributes {
|
||||
tags["id"] = attr[1]
|
||||
tags["name"] = attr[2]
|
||||
|
@ -351,7 +352,7 @@ func gatherDisk(acc telegraf.Accumulator, timeout internal.Duration, usesudo, co
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if collectAttributes {
|
||||
// what was found is not a vendor attribute
|
||||
if matches := sasNvmeAttr.FindStringSubmatch(line); len(matches) > 2 {
|
||||
if attr, ok := sasNvmeAttributes[matches[1]]; ok {
|
||||
tags["name"] = attr.Name
|
||||
|
@ -367,7 +368,9 @@ func gatherDisk(acc telegraf.Accumulator, timeout internal.Duration, usesudo, co
|
|||
if err := parse(fields, deviceFields, matches[2]); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// if the field is classified as an attribute, only add it
|
||||
// if collectAttributes is true
|
||||
if collectAttributes {
|
||||
acc.AddFields("smart_attribute", fields, tags)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue