Skip to content

Commit

Permalink
Move to gopsutil 3.23.7 and remove the need to set environment variab…
Browse files Browse the repository at this point in the history
…les (#3509)

* Remove gopsutilhelper package

* Move to gopsutil 3.23.7 and remove the need to set environment variables
  • Loading branch information
atoulme authored Aug 18, 2023
1 parent 821b9bd commit 24b62e4
Show file tree
Hide file tree
Showing 30 changed files with 166 additions and 145 deletions.
13 changes: 7 additions & 6 deletions internal/signalfx-agent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ require (
github.com/SAP/go-hdb v1.3.10
github.com/Sectorbob/mlab-ns2 v0.0.0-20171030222938-d3aa0c295a8a
github.com/Showmax/go-fqdn v1.0.0
github.com/StackExchange/wmi v1.2.1
github.com/antonmedv/expr v1.13.0
github.com/aws/aws-sdk-go v1.44.317
github.com/beevik/ntp v1.3.0
Expand Down Expand Up @@ -78,7 +77,7 @@ require (
github.com/prometheus/common v0.44.0
github.com/prometheus/procfs v0.11.1
github.com/samuel/go-zookeeper v0.0.0-20200724154423-2164a8ac840e
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/shirou/gopsutil/v3 v3.23.7
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3
github.com/signalfx/defaults v1.2.2-0.20180531161417-70562fe60657
github.com/signalfx/golib/v3 v3.3.50
Expand Down Expand Up @@ -119,6 +118,7 @@ require (
)

require (
github.com/StackExchange/wmi v1.2.1
github.com/go-errors/errors v1.4.2
github.com/hashicorp/golang-lru v1.0.2
github.com/kr/pretty v0.3.1
Expand Down Expand Up @@ -270,7 +270,8 @@ require (
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/shirou/gopsutil/v3 v3.22.8 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/signalfx/gohistogram v0.0.0-20160107210732-1ccfd2ff5083 // indirect
github.com/signalfx/sapm-proto v0.12.0 // indirect
github.com/smarty/assertions v1.15.0 // indirect
Expand All @@ -279,11 +280,11 @@ require (
github.com/stretchr/objx v0.5.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.etcd.io/etcd/api/v3 v3.5.9 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
Expand Down
22 changes: 13 additions & 9 deletions internal/signalfx-agent/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,12 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod
github.com/sethvargo/go-limiter v0.7.1 h1:wWNhTj0pxjyJ7wuJHpRJpYwJn+bUnjYfw2a85eu5w9U=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil/v3 v3.22.8 h1:a4s3hXogo5mE2PfdfJIonDbstO/P+9JszdfhAHSzD9Y=
github.com/shirou/gopsutil/v3 v3.22.8/go.mod h1:s648gW4IywYzUfE/KjXxUsqrqx/T2xO5VqOXxONeRfI=
github.com/shirou/gopsutil/v3 v3.23.7 h1:C+fHO8hfIppoJ1WdsVm1RoI0RwXoNdfTK7yWXV0wVj4=
github.com/shirou/gopsutil/v3 v3.23.7/go.mod h1:c4gnmoRC0hQuaLqvxnx1//VXQ0Ms/X9UnJF8pddY5z4=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
Expand Down Expand Up @@ -1101,10 +1105,10 @@ github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c h1:u6SKchux2yDvFQnDHS3lPnIRmfVJ5Sxy3ao2SIdysLQ=
github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o=
Expand All @@ -1128,8 +1132,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
Expand Down Expand Up @@ -1431,7 +1435,6 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -1441,6 +1444,7 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
13 changes: 8 additions & 5 deletions internal/signalfx-agent/pkg/core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/mitchellh/hashstructure"
log "github.com/sirupsen/logrus"

"github.com/shirou/gopsutil/v3/common"
"github.com/signalfx/signalfx-agent/pkg/core/common/constants"
"github.com/signalfx/signalfx-agent/pkg/core/config/sources"
"github.com/signalfx/signalfx-agent/pkg/core/config/validation"
Expand Down Expand Up @@ -209,11 +210,13 @@ func (c *Config) setupEnvironment() {

os.Setenv("JAVA_HOME", filepath.Join(c.BundleDir, "jre"))
// set the environment variables for gopsutil based on configured values
os.Setenv(hostfs.HostProcVar, c.ProcPath)
os.Setenv(hostfs.HostEtcVar, c.EtcPath)
os.Setenv(hostfs.HostVarVar, c.VarPath)
os.Setenv(hostfs.HostRunVar, c.RunPath)
os.Setenv(hostfs.HostSysVar, c.SysPath)
hostfs.SetEnvMap(common.EnvMap{
common.HostProcEnvKey: c.ProcPath,
common.HostEtcEnvKey: c.EtcPath,
common.HostVarEnvKey: c.VarPath,
common.HostRunEnvKey: c.RunPath,
common.HostSysEnvKey: c.SysPath,
})
}

// Validate everything that we can about the main config
Expand Down
2 changes: 1 addition & 1 deletion internal/signalfx-agent/pkg/monitors/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/signalfx/golib/v3/datapoint"
"github.com/signalfx/golib/v3/sfxclient"
"github.com/sirupsen/logrus"
Expand Down
5 changes: 3 additions & 2 deletions internal/signalfx-agent/pkg/monitors/cpu/cpu_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
package cpu

import (
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/signalfx/signalfx-agent/pkg/utils/hostfs"
)

func (m *Monitor) times(perCore bool) ([]cpu.TimesStat, error) {
return cpu.Times(perCore)
return cpu.TimesWithContext(hostfs.Context(), perCore)
}
10 changes: 6 additions & 4 deletions internal/signalfx-agent/pkg/monitors/cpu/cpu_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"fmt"
"unsafe"

"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/v3/cpu"
"golang.org/x/sys/windows"

"github.com/signalfx/signalfx-agent/pkg/utils/hostfs"
)

const (
Expand All @@ -25,7 +27,7 @@ const (

// set gopsutil function to package variable for easier testing
var (
gopsutilTimes = cpu.Times
gopsutilTimes = cpu.TimesWithContext

// Windows API DLL
ntdll = windows.NewLazySystemDLL("Ntdll.dll")
Expand Down Expand Up @@ -129,7 +131,7 @@ func (m *Monitor) times(perCore bool) ([]cpu.TimesStat, error) {
// non-percore utilization in gopsutil does not rely on wmi so it's fine to
// utilize it as is
if !perCore {
return gopsutilTimes(perCore)
return gopsutilTimes(hostfs.Context(), perCore)
}
// Underneath the hood gopsutil relies on a wmi query for per core cpu utilization information
// this wmi query has proven to be problematic under unclear conditions. It will hang
Expand All @@ -147,5 +149,5 @@ func (m *Monitor) times(perCore bool) ([]cpu.TimesStat, error) {

// fall back to gopsutil if there was an error or the dll and proc weren't loaded/found
m.logger.WithField("debug", err).Debugf("falling back to gopsutil for per core cpu times")
return gopsutilTimes(perCore)
return gopsutilTimes(hostfs.Context(), perCore)
}
7 changes: 4 additions & 3 deletions internal/signalfx-agent/pkg/monitors/diskio/diskio_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (
"strings"
"time"

"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/v3/disk"
"github.com/signalfx/golib/v3/datapoint"
"github.com/signalfx/golib/v3/sfxclient"
"github.com/sirupsen/logrus"

"github.com/signalfx/signalfx-agent/pkg/monitors/types"
"github.com/signalfx/signalfx-agent/pkg/utils"
"github.com/signalfx/signalfx-agent/pkg/utils/filter"
"github.com/signalfx/signalfx-agent/pkg/utils/hostfs"
)

var iOCounters = disk.IOCounters
var iOCounters = disk.IOCountersWithContext

// Monitor for Utilization
type Monitor struct {
Expand Down Expand Up @@ -46,7 +47,7 @@ func (m *Monitor) makeLinuxDatapoints(disk disk.IOCountersStat, dimensions map[s

// EmitDatapoints emits a set of memory datapoints
func (m *Monitor) emitDatapoints() {
iocounts, err := iOCounters()
iocounts, err := iOCounters(hostfs.Context())
if err != nil {
m.logger.WithError(err).Errorf("Failed to load disk io counters")
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

gopsutil "github.com/shirou/gopsutil/disk"
gopsutil "github.com/shirou/gopsutil/v3/disk"
"github.com/signalfx/golib/v3/datapoint"
log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -72,7 +72,7 @@ func (m *Monitor) getCommonDimensions(partition *gopsutil.PartitionStat) map[str
}
if m.sendModeDimension {
var mode string
opts := strings.Split(partition.Opts, ",")
opts := partition.Opts
for _, opt := range opts {
if opt == "ro" || opt == "rw" {
mode = opt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package filesystems
import (
"testing"

gopsutil "github.com/shirou/gopsutil/disk"
gopsutil "github.com/shirou/gopsutil/v3/disk"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
Expand All @@ -20,7 +20,7 @@ func TestCommonDimensions(t *testing.T) {
Device: "/dev/sdb1",
Mountpoint: "/hostfs/var/lib",
Fstype: "ext4",
Opts: "rw,relatime",
Opts: []string{"rw", "relatime"},
},
expectedDims: map[string]string{
"mountpoint": "/var/lib",
Expand All @@ -35,7 +35,7 @@ func TestCommonDimensions(t *testing.T) {
Device: "/dev/sdb1",
Mountpoint: "/hostfs",
Fstype: "ext4",
Opts: "ro,relatime",
Opts: []string{"ro", "relatime"},
},
expectedDims: map[string]string{
"mountpoint": "/",
Expand All @@ -50,7 +50,7 @@ func TestCommonDimensions(t *testing.T) {
Device: "/dev/sdb1",
Mountpoint: "/",
Fstype: "ext4",
Opts: "rx,relatime",
Opts: []string{"rx", "relatime"},
},
expectedDims: map[string]string{
"mountpoint": "/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package filesystems
import (
"path/filepath"

gopsutil "github.com/shirou/gopsutil/disk"
gopsutil "github.com/shirou/gopsutil/v3/disk"
"github.com/signalfx/signalfx-agent/pkg/utils/hostfs"
)

func getPartitions(all bool) ([]gopsutil.PartitionStat, error) {
return gopsutil.Partitions(all)
return gopsutil.PartitionsWithContext(hostfs.Context(), all)
}

// getUsage prepends the hostFSPath to the partition mountpoint. This is needed
Expand All @@ -20,5 +21,5 @@ func getUsage(hostFSPath string, path string) (*gopsutil.UsageStat, error) {
if hostFSPath != "" {
path = filepath.Join(hostFSPath, path)
}
return gopsutil.Usage(path)
return gopsutil.UsageWithContext(hostfs.Context(), path)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import (
"syscall"
"unicode/utf16"

gopsutil "github.com/shirou/gopsutil/disk"
gopsutil "github.com/shirou/gopsutil/v3/disk"
"golang.org/x/sys/windows"
)

const volumeNameBufferLength = uint32(windows.MAX_PATH + 1)
const volumePathBufferLength = volumeNameBufferLength

// Copied from https://github.com/shirou/gopsutil/blob/master/disk/disk_windows.go#L25C1-L25C1
var (
fileFileCompression = int64(16) // 0x00000010
fileReadOnlyVolume = int64(524288) // 0x00080000
)

func getPartitions(all bool) ([]gopsutil.PartitionStat, error) {
return getPartitionsWin(getDriveType, findFirstVolume, findNextVolume, findVolumeClose, getVolumePaths, getFsNameAndFlags)
}
Expand Down Expand Up @@ -176,12 +182,12 @@ func getPartitionStats(
continue
}

opts := "rw"
if int64(fsFlags)&gopsutil.FileReadOnlyVolume != 0 {
opts = "ro"
opts := []string{"rw"}
if int64(fsFlags)&fileReadOnlyVolume != 0 {
opts = []string{"ro"}
}
if int64(fsFlags)&gopsutil.FileFileCompression != 0 {
opts += ".compress"
if int64(fsFlags)&fileFileCompression != 0 {
opts = append(opts, ".compress")
}

p := strings.TrimRight(volPath, "\\")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"unsafe"

gopsutil "github.com/shirou/gopsutil/disk"
gopsutil "github.com/shirou/gopsutil/v3/disk"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sys/windows"
Expand Down Expand Up @@ -104,10 +104,10 @@ func TestGetPartitionsWin(t *testing.T) {
numStats: 4,
hasError: false,
stats: []gopsutil.PartitionStat{
{Device: "C:", Mountpoint: "C:", Fstype: "NTFS", Opts: "rw.compress"},
{Device: "D:", Mountpoint: "D:", Fstype: "NTFS", Opts: "ro.compress"},
{Device: "C:\\mnt\\driveD", Mountpoint: "C:\\mnt\\driveD", Fstype: "NTFS", Opts: "ro.compress"},
{Device: "A:", Mountpoint: "A:", Fstype: "FAT16", Opts: "rw.compress"}},
{Device: "C:", Mountpoint: "C:", Fstype: "NTFS", Opts: []string{"rw", ".compress"}},
{Device: "D:", Mountpoint: "D:", Fstype: "NTFS", Opts: []string{"ro", ".compress"}},
{Device: "C:\\mnt\\driveD", Mountpoint: "C:\\mnt\\driveD", Fstype: "NTFS", Opts: []string{"ro", ".compress"}},
{Device: "A:", Mountpoint: "A:", Fstype: "FAT16", Opts: []string{"rw", ".compress"}}},
},
},
{
Expand Down Expand Up @@ -136,8 +136,8 @@ func TestGetPartitionsWin(t *testing.T) {
numStats: 2,
hasError: true,
stats: []gopsutil.PartitionStat{
{Device: "C:", Mountpoint: "C:", Fstype: "NTFS", Opts: "rw.compress"},
{Device: "A:", Mountpoint: "A:", Fstype: "FAT16", Opts: "rw.compress"}},
{Device: "C:", Mountpoint: "C:", Fstype: "NTFS", Opts: []string{"rw", ".compress"}},
{Device: "A:", Mountpoint: "A:", Fstype: "FAT16", Opts: []string{"rw", ".compress"}}},
},
},
}
Expand Down
5 changes: 3 additions & 2 deletions internal/signalfx-agent/pkg/monitors/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"runtime"
"time"

"github.com/shirou/gopsutil/load"
"github.com/shirou/gopsutil/v3/load"
"github.com/signalfx/golib/v3/datapoint"
"github.com/sirupsen/logrus"

"github.com/signalfx/signalfx-agent/pkg/core/config"
"github.com/signalfx/signalfx-agent/pkg/monitors"
"github.com/signalfx/signalfx-agent/pkg/monitors/types"
"github.com/signalfx/signalfx-agent/pkg/utils"
"github.com/signalfx/signalfx-agent/pkg/utils/hostfs"
)

func init() {
Expand Down Expand Up @@ -45,7 +46,7 @@ func (m *Monitor) Configure(conf *Config) error {

// gather metrics on the specified interval
utils.RunOnInterval(ctx, func() {
avgLoad, err := load.Avg()
avgLoad, err := load.AvgWithContext(hostfs.Context())
if err != nil {
m.logger.WithError(err).Error("Failed to get load statistics")
return
Expand Down
Loading

0 comments on commit 24b62e4

Please sign in to comment.