Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Improve performance of host observer
Browse files Browse the repository at this point in the history
This skips the uid lookup since we don't use it. See upstream PRs
for some more background:

shirou/gopsutil#784
shirou/gopsutil#783

This requires upgrading gopsutil which changed some structs which in
turn requires upgrading telegraf. Apparently the `Stolen` field was never set
(shirou/gopsutil#677)

Even with this change there are still some performance issues in the host
observer on machines with a large number of connections. Something like this
change would be required to deal with the remaining issues:

shirou/gopsutil#695
  • Loading branch information
Jay Camp committed Jan 21, 2020
1 parent a3c5b1e commit 5b60428
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ require (
github.com/influxdata/influxdb v1.7.4 // indirect
github.com/influxdata/platform v0.0.0-20190117200541-d500d3cf5589 // indirect
github.com/influxdata/tail v1.0.0 // indirect
github.com/influxdata/telegraf v0.10.2-0.20190319005412-5e88824c153e
github.com/influxdata/telegraf v0.10.2-0.20200121190823-6dad859d74c2
github.com/influxdata/toml v0.0.0-20180607005434-2a2e3012f7cf // indirect
github.com/influxdata/wlog v0.0.0-20160411224016-7c63b0a71ef8 // indirect
github.com/jaegertracing/jaeger v1.15.1
Expand Down Expand Up @@ -122,15 +122,15 @@ require (
github.com/prometheus/common v0.2.1-0.20190321124555-1ab4d74fc899
github.com/prometheus/procfs v0.0.9-0.20191209220459-fa4d6ce8c078
github.com/samuel/go-zookeeper v0.0.0-20190810000440-0ceca61e4d75
github.com/shirou/gopsutil v2.18.12+incompatible
github.com/shirou/gopsutil v2.19.12+incompatible
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.0-20190222193949-1fb69526e884
github.com/signalfx/defaults v1.2.2-0.20180531161417-70562fe60657
github.com/signalfx/gateway v1.2.19-0.20191125135538-2c417b7ae0bd
github.com/signalfx/golib/v3 v3.1.0
github.com/signalfx/signalfx-go v1.6.9-0.20191121015807-da8b1dfaab43
github.com/sirupsen/logrus v1.4.0
github.com/smartystreets/goconvey v1.6.4
github.com/soniah/gosnmp v0.0.0-20190220004421-68e8beac0db9 // indirect
github.com/soniah/gosnmp v1.22.0 // indirect
github.com/streadway/amqp v0.0.0-20190312223743-14f78b41ce6d // indirect
github.com/stretchr/testify v1.4.0
github.com/tidwall/gjson v1.2.1 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ github.com/influxdata/tail v1.0.0/go.mod h1:xTFF2SILpIYc5N+Srb0d5qpx7d+f733nBrba
github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0=
github.com/influxdata/telegraf v0.10.2-0.20190319005412-5e88824c153e h1:tfGPLDKE2X1PaU0TQn7H0ZkoNrcVW2a33CnSd8uSTi4=
github.com/influxdata/telegraf v0.10.2-0.20190319005412-5e88824c153e/go.mod h1:HIOhVICa+3kYiBmzfDt9LEnDA++FNzRzf9eP0o365us=
github.com/influxdata/telegraf v0.10.2-0.20200121190823-6dad859d74c2 h1:7+1SwH+Qw6NRc5SWThS5bkVjeG1T4yDBVpDAECWQmQ0=
github.com/influxdata/telegraf v0.10.2-0.20200121190823-6dad859d74c2/go.mod h1:HIOhVICa+3kYiBmzfDt9LEnDA++FNzRzf9eP0o365us=
github.com/influxdata/toml v0.0.0-20180607005434-2a2e3012f7cf h1:SDlFXYATjEbWThjvSTGdLmHyPozB8QsUFQs/LQ/bOcE=
github.com/influxdata/toml v0.0.0-20180607005434-2a2e3012f7cf/go.mod h1:zApaNFpP/bTpQItGZNNUMISDMDAnTXu9UqJ4yT3ocz8=
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po=
Expand Down Expand Up @@ -757,6 +759,8 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
github.com/shirou/gopsutil v2.18.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM=
github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v2.19.12+incompatible h1:WRstheAymn1WOPesh+24+bZKFkqrdCR8JOc77v4xV3Q=
github.com/shirou/gopsutil v2.19.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.0-20190222193949-1fb69526e884 h1:KgLGEw137KEUtQnWBGzneCetphBj4+kKHRnhpAkXJC0=
Expand Down Expand Up @@ -814,6 +818,8 @@ github.com/soheilhy/cmux v0.1.5-0.20181025144106-8a8ea3c53959 h1:AulKUH62UkjPFbb
github.com/soheilhy/cmux v0.1.5-0.20181025144106-8a8ea3c53959/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/soniah/gosnmp v0.0.0-20190220004421-68e8beac0db9 h1:O4jq14rgUwG9Ssn0wZiRPl8Ya6q3a1h3xJzTAsBaRgo=
github.com/soniah/gosnmp v0.0.0-20190220004421-68e8beac0db9/go.mod h1:DuEpAS0az51+DyVBQwITDsoq4++e3LTNckp2GoasF2I=
github.com/soniah/gosnmp v1.22.0 h1:jVJi8+OGvR+JHIaZKMmnyNP0akJd2vEgNatybwhZvxg=
github.com/soniah/gosnmp v1.22.0/go.mod h1:DuEpAS0az51+DyVBQwITDsoq4++e3LTNckp2GoasF2I=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand Down
3 changes: 1 addition & 2 deletions pkg/monitors/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ func cpuTimeStatTototalUsed(t *cpu.TimesStat) *totalUsed {
t.Softirq +
t.Steal +
t.Guest +
t.GuestNice +
t.Stolen
t.GuestNice

return &totalUsed{
Total: total,
Expand Down
2 changes: 1 addition & 1 deletion pkg/monitors/telegraf/common/accumulator/accumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (ac *Accumulator) AddHistogram(measurement string, fields map[string]interf
}

// SetPrecision - SignalFx does not implement this
func (ac *Accumulator) SetPrecision(precision, interval time.Duration) {
func (ac *Accumulator) SetPrecision(precision time.Duration) {
}

// AddError - log an error returned by the plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestAccumulator(t *testing.T) {
}
t.Run("SetPrecision()", func(t *testing.T) {
ac.emit = &testEmitter{}
ac.SetPrecision(time.Second*1, time.Second*1)
ac.SetPrecision(time.Second * 1)
})
t.Run("AddError()", func(t *testing.T) {
ac.emit = &testEmitter{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/observers/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func portTypeToProtocol(t uint32) services.PortType {
}

func (o *Observer) discover() []services.Endpoint {
conns, err := net.Connections("all")
conns, err := net.ConnectionsWithoutUids("all")
if err != nil {
o.logger.WithError(err).Error("Could not get local network listeners")
return nil
Expand Down

0 comments on commit 5b60428

Please sign in to comment.