skip disk tags with no value

Influxdb 0.9.1 now rejects writes with empty tag values. This patch skips tags with no values. A disk serial number does not exist for many devices including md raid arrays and VMs. Other plugins may also want to check for empty tags.
This commit is contained in:
Joe Hofeditz 2015-07-03 08:11:52 -06:00
parent e9ad786578
commit 073b1084b7
1 changed files with 6 additions and 3 deletions

View File

@ -55,9 +55,12 @@ func (s *DiskIOStats) Gather(acc plugins.Accumulator) error {
}
for _, io := range diskio {
tags := map[string]string{
"name": io.Name,
"serial": io.SerialNumber,
tags := map[string]string{}
if len(io.Name) != 0 {
tags["name"] = io.Name
}
if len(io.SerialNumber) != 0 {
tags["serial"] = io.SerialNumber
}
acc.Add("reads", io.ReadCount, tags)