Skip to content

Move to gopsutil 3.23.7 and remove the need to set environment variables #3509

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

Merged
merged 2 commits into from
Aug 18, 2023
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
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)
}
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