Skip to content

Commit

Permalink
io plugin, add an 'unknown' tag when the serial number can't be found
Browse files Browse the repository at this point in the history
closes #405
  • Loading branch information
sparrc committed Dec 2, 2015
1 parent a844c1a commit 6fb7d28
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v0.2.4 [unreleased]

### Features
- [#412](https://github.com/influxdb/telegraf/pull/412): Additional memcached stats. Thanks @mgresser!
- [#410](https://github.com/influxdb/telegraf/pull/410): Additional redis metrics. Thanks @vlaadbrain!

### Bugfixes
- [#405](https://github.com/influxdb/telegraf/issues/405): Prometheus output cardinality issue

## v0.2.3 [2015-11-30]

### Release Notes
Expand Down
18 changes: 10 additions & 8 deletions plugins/system/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ func (_ *DiskIOStats) Description() string {
}

var diskIoSampleConfig = `
# By default, telegraf will gather stats for all devices including
# By default, telegraf will gather stats for all devices including
# disk partitions.
# Setting devices will restrict the stats to the specified devcies.
# Devices=["sda","sdb"]
# devices = ["sda","sdb"]
# Uncomment the following line if you do not need disk serial numbers.
# SkipSerialNumber = true
# skip_serial_number = true
`

func (_ *DiskIOStats) SampleConfig() string {
Expand Down Expand Up @@ -106,11 +106,13 @@ func (s *DiskIOStats) Gather(acc plugins.Accumulator) error {
continue
}
tags := map[string]string{}
if len(io.Name) != 0 {
tags["name"] = io.Name
}
if len(io.SerialNumber) != 0 && !s.SkipSerialNumber {
tags["serial"] = io.SerialNumber
tags["name"] = io.Name
if !s.SkipSerialNumber {
if len(io.SerialNumber) != 0 {
tags["serial"] = io.SerialNumber
} else {
tags["serial"] = "unknown"
}
}

acc.Add("reads", io.ReadCount, tags)
Expand Down

0 comments on commit 6fb7d28

Please sign in to comment.