Add device, serial_no, and wwn tags to synthetic attributes (#6040)

This commit is contained in:
Daniel Nelson
2019-06-25 11:51:51 -07:00
committed by GitHub
parent e1cfc9f3a0
commit e8a596858c
2 changed files with 69 additions and 11 deletions

View File

@@ -253,18 +253,21 @@ func gatherDisk(acc telegraf.Accumulator, usesudo, collectAttributes bool, smart
tags := map[string]string{}
fields := make(map[string]interface{})
if collectAttributes {
deviceNode := strings.Split(device, " ")[0]
tags["device"] = path.Base(deviceNode)
if serial, ok := deviceTags["serial_no"]; ok {
tags["serial_no"] = serial
}
if wwn, ok := deviceTags["wwn"]; ok {
tags["wwn"] = wwn
}
}
attr := attribute.FindStringSubmatch(line)
if len(attr) > 1 {
if collectAttributes {
deviceNode := strings.Split(device, " ")[0]
tags["device"] = path.Base(deviceNode)
if serial, ok := deviceTags["serial_no"]; ok {
tags["serial_no"] = serial
}
if wwn, ok := deviceTags["wwn"]; ok {
tags["wwn"] = wwn
}
tags["id"] = attr[1]
tags["name"] = attr[2]
tags["flags"] = attr[3]