Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gopsutil dependency #1234

Merged
merged 1 commit into from
May 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [#1138](https://github.com/influxdata/telegraf/pull/1138): nstat input plugin. Thanks @Maksadbek!
- [#1139](https://github.com/influxdata/telegraf/pull/1139): instrumental output plugin. Thanks @jasonroelofs!
- [#1172](https://github.com/influxdata/telegraf/pull/1172): Ceph storage stats. Thanks @robinpercy!
- [#1233](https://github.com/influxdata/telegraf/pull/1233): Updated golint gopsutil dependency.

### Bugfixes

Expand Down
2 changes: 1 addition & 1 deletion Godeps
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6
github.com/prometheus/common e8eabff8812b05acf522b45fdcd725a785188e37
github.com/prometheus/procfs 406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8
github.com/samuel/go-zookeeper 218e9c81c0dd8b3b18172b2bbfad92cc7d6db55f
github.com/shirou/gopsutil 37d89088411de59a4ef9fc340afa0e89dfcb4ea9
github.com/shirou/gopsutil bae75faa5ad1212d3e80f11f5e9cd147c6be9198
github.com/soniah/gosnmp b1b4f885b12c5dcbd021c5cee1c904110de6db7d
github.com/streadway/amqp b4f3ceab0337f013208d31348b578d83c0064744
github.com/stretchr/testify 1f4a1643a57e798696635ea4c126e9127adb7d3c
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/procstat/spec_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (p *SpecProcessor) pushMetrics() {
fields[prefix+"write_bytes"] = io.WriteCount
}

cpu_time, err := p.proc.CPUTimes()
cpu_time, err := p.proc.Times()
if err == nil {
fields[prefix+"cpu_time_user"] = cpu_time.User
fields[prefix+"cpu_time_system"] = cpu_time.System
Expand All @@ -86,7 +86,7 @@ func (p *SpecProcessor) pushMetrics() {
fields[prefix+"cpu_time_guest_nice"] = cpu_time.GuestNice
}

cpu_perc, err := p.proc.CPUPercent(time.Duration(0))
cpu_perc, err := p.proc.Percent(time.Duration(0))
if err == nil && cpu_perc != 0 {
fields[prefix+"cpu_usage"] = cpu_perc
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/system/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type CPUStats struct {
ps PS
lastStats []cpu.CPUTimesStat
lastStats []cpu.TimesStat

PerCPU bool `toml:"percpu"`
TotalCPU bool `toml:"totalcpu"`
Expand Down Expand Up @@ -105,7 +105,7 @@ func (s *CPUStats) Gather(acc telegraf.Accumulator) error {
return nil
}

func totalCpuTime(t cpu.CPUTimesStat) float64 {
func totalCpuTime(t cpu.TimesStat) float64 {
total := t.User + t.System + t.Nice + t.Iowait + t.Irq + t.Softirq + t.Steal +
t.Guest + t.GuestNice + t.Idle
return total
Expand Down
8 changes: 4 additions & 4 deletions plugins/inputs/system/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestCPUStats(t *testing.T) {
defer mps.AssertExpectations(t)
var acc testutil.Accumulator

cts := cpu.CPUTimesStat{
cts := cpu.TimesStat{
CPU: "cpu0",
User: 3.1,
System: 8.2,
Expand All @@ -29,7 +29,7 @@ func TestCPUStats(t *testing.T) {
GuestNice: 0.324,
}

cts2 := cpu.CPUTimesStat{
cts2 := cpu.TimesStat{
CPU: "cpu0",
User: 11.4, // increased by 8.3
System: 10.9, // increased by 2.7
Expand All @@ -43,7 +43,7 @@ func TestCPUStats(t *testing.T) {
GuestNice: 2.524, // increased by 2.2
}

mps.On("CPUTimes").Return([]cpu.CPUTimesStat{cts}, nil)
mps.On("CPUTimes").Return([]cpu.TimesStat{cts}, nil)

cs := NewCPUStats(&mps)

Expand All @@ -68,7 +68,7 @@ func TestCPUStats(t *testing.T) {
assertContainsTaggedFloat(t, &acc, "cpu", "time_guest_nice", 0.324, 0, cputags)

mps2 := MockPS{}
mps2.On("CPUTimes").Return([]cpu.CPUTimesStat{cts2}, nil)
mps2.On("CPUTimes").Return([]cpu.TimesStat{cts2}, nil)
cs.ps = &mps2

// Should have added cpu percentages too
Expand Down
10 changes: 5 additions & 5 deletions plugins/inputs/system/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestDiskStats(t *testing.T) {
var acc testutil.Accumulator
var err error

duAll := []*disk.DiskUsageStat{
duAll := []*disk.UsageStat{
{
Path: "/",
Fstype: "ext4",
Expand All @@ -37,7 +37,7 @@ func TestDiskStats(t *testing.T) {
InodesUsed: 2000,
},
}
duFiltered := []*disk.DiskUsageStat{
duFiltered := []*disk.UsageStat{
{
Path: "/",
Fstype: "ext4",
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestDiskStats(t *testing.T) {
// var acc testutil.Accumulator
// var err error

// diskio1 := disk.DiskIOCountersStat{
// diskio1 := disk.IOCountersStat{
// ReadCount: 888,
// WriteCount: 5341,
// ReadBytes: 100000,
Expand All @@ -119,7 +119,7 @@ func TestDiskStats(t *testing.T) {
// IoTime: 123552,
// SerialNumber: "ab-123-ad",
// }
// diskio2 := disk.DiskIOCountersStat{
// diskio2 := disk.IOCountersStat{
// ReadCount: 444,
// WriteCount: 2341,
// ReadBytes: 200000,
Expand All @@ -132,7 +132,7 @@ func TestDiskStats(t *testing.T) {
// }

// mps.On("DiskIO").Return(
// map[string]disk.DiskIOCountersStat{"sda1": diskio1, "sdb1": diskio2},
// map[string]disk.IOCountersStat{"sda1": diskio1, "sdb1": diskio2},
// nil)

// err = (&DiskIOStats{ps: &mps}).Gather(&acc)
Expand Down
28 changes: 14 additions & 14 deletions plugins/inputs/system/mock_PS.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,55 @@ type MockPS struct {
mock.Mock
}

func (m *MockPS) LoadAvg() (*load.LoadAvgStat, error) {
func (m *MockPS) LoadAvg() (*load.AvgStat, error) {
ret := m.Called()

r0 := ret.Get(0).(*load.LoadAvgStat)
r0 := ret.Get(0).(*load.AvgStat)
r1 := ret.Error(1)

return r0, r1
}

func (m *MockPS) CPUTimes(perCPU, totalCPU bool) ([]cpu.CPUTimesStat, error) {
func (m *MockPS) CPUTimes(perCPU, totalCPU bool) ([]cpu.TimesStat, error) {
ret := m.Called()

r0 := ret.Get(0).([]cpu.CPUTimesStat)
r0 := ret.Get(0).([]cpu.TimesStat)
r1 := ret.Error(1)

return r0, r1
}

func (m *MockPS) DiskUsage(mountPointFilter []string, fstypeExclude []string) ([]*disk.DiskUsageStat, error) {
func (m *MockPS) DiskUsage(mountPointFilter []string, fstypeExclude []string) ([]*disk.UsageStat, error) {
ret := m.Called(mountPointFilter, fstypeExclude)

r0 := ret.Get(0).([]*disk.DiskUsageStat)
r0 := ret.Get(0).([]*disk.UsageStat)
r1 := ret.Error(1)

return r0, r1
}

func (m *MockPS) NetIO() ([]net.NetIOCountersStat, error) {
func (m *MockPS) NetIO() ([]net.IOCountersStat, error) {
ret := m.Called()

r0 := ret.Get(0).([]net.NetIOCountersStat)
r0 := ret.Get(0).([]net.IOCountersStat)
r1 := ret.Error(1)

return r0, r1
}

func (m *MockPS) NetProto() ([]net.NetProtoCountersStat, error) {
func (m *MockPS) NetProto() ([]net.ProtoCountersStat, error) {
ret := m.Called()

r0 := ret.Get(0).([]net.NetProtoCountersStat)
r0 := ret.Get(0).([]net.ProtoCountersStat)
r1 := ret.Error(1)

return r0, r1
}

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

r0 := ret.Get(0).(map[string]disk.DiskIOCountersStat)
r0 := ret.Get(0).(map[string]disk.IOCountersStat)
r1 := ret.Error(1)

return r0, r1
Expand All @@ -87,10 +87,10 @@ func (m *MockPS) SwapStat() (*mem.SwapMemoryStat, error) {
return r0, r1
}

func (m *MockPS) NetConnections() ([]net.NetConnectionStat, error) {
func (m *MockPS) NetConnections() ([]net.ConnectionStat, error) {
ret := m.Called()

r0 := ret.Get(0).([]net.NetConnectionStat)
r0 := ret.Get(0).([]net.ConnectionStat)
r1 := ret.Error(1)

return r0, r1
Expand Down
18 changes: 9 additions & 9 deletions plugins/inputs/system/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestNetStats(t *testing.T) {
defer mps.AssertExpectations(t)
var acc testutil.Accumulator

netio := net.NetIOCountersStat{
netio := net.IOCountersStat{
Name: "eth0",
BytesSent: 1123,
BytesRecv: 8734422,
Expand All @@ -27,10 +27,10 @@ func TestNetStats(t *testing.T) {
Dropout: 1,
}

mps.On("NetIO").Return([]net.NetIOCountersStat{netio}, nil)
mps.On("NetIO").Return([]net.IOCountersStat{netio}, nil)

netprotos := []net.NetProtoCountersStat{
net.NetProtoCountersStat{
netprotos := []net.ProtoCountersStat{
net.ProtoCountersStat{
Protocol: "Udp",
Stats: map[string]int64{
"InDatagrams": 4655,
Expand All @@ -40,17 +40,17 @@ func TestNetStats(t *testing.T) {
}
mps.On("NetProto").Return(netprotos, nil)

netstats := []net.NetConnectionStat{
net.NetConnectionStat{
netstats := []net.ConnectionStat{
net.ConnectionStat{
Type: syscall.SOCK_DGRAM,
},
net.NetConnectionStat{
net.ConnectionStat{
Status: "ESTABLISHED",
},
net.NetConnectionStat{
net.ConnectionStat{
Status: "ESTABLISHED",
},
net.NetConnectionStat{
net.ConnectionStat{
Status: "CLOSE",
},
}
Expand Down
44 changes: 22 additions & 22 deletions plugins/inputs/system/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
)

type PS interface {
CPUTimes(perCPU, totalCPU bool) ([]cpu.CPUTimesStat, error)
DiskUsage(mountPointFilter []string, fstypeExclude []string) ([]*disk.DiskUsageStat, error)
NetIO() ([]net.NetIOCountersStat, error)
NetProto() ([]net.NetProtoCountersStat, error)
DiskIO() (map[string]disk.DiskIOCountersStat, error)
CPUTimes(perCPU, totalCPU bool) ([]cpu.TimesStat, error)
DiskUsage(mountPointFilter []string, fstypeExclude []string) ([]*disk.UsageStat, error)
NetIO() ([]net.IOCountersStat, error)
NetProto() ([]net.ProtoCountersStat, error)
DiskIO() (map[string]disk.IOCountersStat, error)
VMStat() (*mem.VirtualMemoryStat, error)
SwapStat() (*mem.SwapMemoryStat, error)
NetConnections() ([]net.NetConnectionStat, error)
NetConnections() ([]net.ConnectionStat, error)
}

func add(acc telegraf.Accumulator,
Expand All @@ -32,17 +32,17 @@ func add(acc telegraf.Accumulator,

type systemPS struct{}

func (s *systemPS) CPUTimes(perCPU, totalCPU bool) ([]cpu.CPUTimesStat, error) {
var cpuTimes []cpu.CPUTimesStat
func (s *systemPS) CPUTimes(perCPU, totalCPU bool) ([]cpu.TimesStat, error) {
var cpuTimes []cpu.TimesStat
if perCPU {
if perCPUTimes, err := cpu.CPUTimes(true); err == nil {
if perCPUTimes, err := cpu.Times(true); err == nil {
cpuTimes = append(cpuTimes, perCPUTimes...)
} else {
return nil, err
}
}
if totalCPU {
if totalCPUTimes, err := cpu.CPUTimes(false); err == nil {
if totalCPUTimes, err := cpu.Times(false); err == nil {
cpuTimes = append(cpuTimes, totalCPUTimes...)
} else {
return nil, err
Expand All @@ -54,8 +54,8 @@ func (s *systemPS) CPUTimes(perCPU, totalCPU bool) ([]cpu.CPUTimesStat, error) {
func (s *systemPS) DiskUsage(
mountPointFilter []string,
fstypeExclude []string,
) ([]*disk.DiskUsageStat, error) {
parts, err := disk.DiskPartitions(true)
) ([]*disk.UsageStat, error) {
parts, err := disk.Partitions(true)
if err != nil {
return nil, err
}
Expand All @@ -70,7 +70,7 @@ func (s *systemPS) DiskUsage(
fstypeExcludeSet[filter] = true
}

var usage []*disk.DiskUsageStat
var usage []*disk.UsageStat

for _, p := range parts {
if len(mountPointFilter) > 0 {
Expand All @@ -83,7 +83,7 @@ func (s *systemPS) DiskUsage(
}
mountpoint := os.Getenv("HOST_MOUNT_PREFIX") + p.Mountpoint
if _, err := os.Stat(mountpoint); err == nil {
du, err := disk.DiskUsage(mountpoint)
du, err := disk.Usage(mountpoint)
du.Path = p.Mountpoint
if err != nil {
return nil, err
Expand All @@ -102,20 +102,20 @@ func (s *systemPS) DiskUsage(
return usage, nil
}

func (s *systemPS) NetProto() ([]net.NetProtoCountersStat, error) {
return net.NetProtoCounters(nil)
func (s *systemPS) NetProto() ([]net.ProtoCountersStat, error) {
return net.ProtoCounters(nil)
}

func (s *systemPS) NetIO() ([]net.NetIOCountersStat, error) {
return net.NetIOCounters(true)
func (s *systemPS) NetIO() ([]net.IOCountersStat, error) {
return net.IOCounters(true)
}

func (s *systemPS) NetConnections() ([]net.NetConnectionStat, error) {
return net.NetConnections("all")
func (s *systemPS) NetConnections() ([]net.ConnectionStat, error) {
return net.Connections("all")
}

func (s *systemPS) DiskIO() (map[string]disk.DiskIOCountersStat, error) {
m, err := disk.DiskIOCounters()
func (s *systemPS) DiskIO() (map[string]disk.IOCountersStat, error) {
m, err := disk.IOCounters()
if err == internal.NotImplementedError {
return nil, nil
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ func (_ *SystemStats) Description() string {
func (_ *SystemStats) SampleConfig() string { return "" }

func (_ *SystemStats) Gather(acc telegraf.Accumulator) error {
loadavg, err := load.LoadAvg()
loadavg, err := load.Avg()
if err != nil {
return err
}

hostinfo, err := host.HostInfo()
hostinfo, err := host.Info()
if err != nil {
return err
}
Expand Down