Skip to content

Commit

Permalink
Use name filter for IOCounters in diskio (#2649)
Browse files Browse the repository at this point in the history
Use IOCountersForNames for disk counters.
  • Loading branch information
danielnelson authored Apr 11, 2017
1 parent fa0f5bd commit 8b4c320
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ be deprecated eventually.
- [#2610](https://github.com/influxdata/telegraf/pull/2610): Fix deadlock when output cannot write
- [#2410](https://github.com/influxdata/telegraf/issues/2410): Fix connection leak in postgresql.
- [#2628](https://github.com/influxdata/telegraf/issues/2628): Set default measurement name for snmp input.
- [#2649](https://github.com/influxdata/telegraf/pull/2649): Improve performance of diskio with many disks

## v1.2.1 [2017-02-01]

Expand Down
2 changes: 1 addition & 1 deletion Godeps
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ github.com/prometheus/common dd2f054febf4a6c00f2343686efb775948a8bff4
github.com/prometheus/procfs 1878d9fbb537119d24b21ca07effd591627cd160
github.com/rcrowley/go-metrics 1f30fe9094a513ce4c700b9a54458bbb0c96996c
github.com/samuel/go-zookeeper 1d7be4effb13d2d908342d349d71a284a7542693
github.com/shirou/gopsutil d371ba1293cb48fedc6850526ea48b3846c54f2c
github.com/shirou/gopsutil dfbb3e40da8d6fcd1aa0d87003e965fe0ca745ea
github.com/soniah/gosnmp 5ad50dc75ab389f8a1c9f8a67d3a1cd85f67ed15
github.com/streadway/amqp 63795daa9a446c920826655f26ba31c81c860fd6
github.com/stretchr/testify 4d4bfba8f1d1027c4fdbe371823030df51419987
Expand Down
15 changes: 1 addition & 14 deletions plugins/inputs/system/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,12 @@ func (_ *DiskIOStats) SampleConfig() string {
}

func (s *DiskIOStats) Gather(acc telegraf.Accumulator) error {
diskio, err := s.ps.DiskIO()
diskio, err := s.ps.DiskIO(s.Devices)
if err != nil {
return fmt.Errorf("error getting disk io info: %s", err)
}

var restrictDevices bool
devices := make(map[string]bool)
if len(s.Devices) != 0 {
restrictDevices = true
for _, dev := range s.Devices {
devices[dev] = true
}
}

for _, io := range diskio {
_, member := devices[io.Name]
if restrictDevices && !member {
continue
}
tags := map[string]string{}
tags["name"] = s.diskName(io.Name)
for t, v := range s.diskTags(io.Name) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/system/mock_PS.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (m *MockPS) NetProto() ([]net.ProtoCountersStat, error) {
return r0, r1
}

func (m *MockPS) DiskIO() (map[string]disk.IOCountersStat, error) {
func (m *MockPS) DiskIO(names []string) (map[string]disk.IOCountersStat, error) {
ret := m.Called()

r0 := ret.Get(0).(map[string]disk.IOCountersStat)
Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/system/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type PS interface {
DiskUsage(mountPointFilter []string, fstypeExclude []string) ([]*disk.UsageStat, []*disk.PartitionStat, error)
NetIO() ([]net.IOCountersStat, error)
NetProto() ([]net.ProtoCountersStat, error)
DiskIO() (map[string]disk.IOCountersStat, error)
DiskIO(names []string) (map[string]disk.IOCountersStat, error)
VMStat() (*mem.VirtualMemoryStat, error)
SwapStat() (*mem.SwapMemoryStat, error)
NetConnections() ([]net.ConnectionStat, error)
Expand Down Expand Up @@ -120,8 +120,8 @@ func (s *systemPS) NetConnections() ([]net.ConnectionStat, error) {
return net.Connections("all")
}

func (s *systemPS) DiskIO() (map[string]disk.IOCountersStat, error) {
m, err := disk.IOCounters()
func (s *systemPS) DiskIO(names []string) (map[string]disk.IOCountersStat, error) {
m, err := disk.IOCountersForNames(names)
if err == internal.NotImplementedError {
return nil, nil
}
Expand Down

0 comments on commit 8b4c320

Please sign in to comment.