Use name filter for IOCounters in diskio (#2649)

Use IOCountersForNames for disk counters.
This commit is contained in:
Daniel Nelson 2017-04-11 11:41:09 -07:00 committed by GitHub
parent 516dffa4c4
commit f55af7d21f
5 changed files with 7 additions and 19 deletions

View File

@ -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]

2
Godeps
View File

@ -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

View File

@ -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) {

View File

@ -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)

View File

@ -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)
@ -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
}