From 67f655bfeb84986060cf86df852ea3d53e848ce4 Mon Sep 17 00:00:00 2001 From: Mingyang Zheng Date: Tue, 15 Oct 2024 04:25:18 -0700 Subject: [PATCH] chore(deps): Bump upgrade github.com/shirou/gopsutil from v3.24.4 to v4.24.9 (#16023) --- docs/LICENSE_OF_DEPENDENCIES.md | 1 + go.mod | 4 +++- go.sum | 4 ++++ plugins/inputs/conntrack/conntrack_test.go | 2 +- plugins/inputs/cpu/cpu.go | 2 +- plugins/inputs/cpu/cpu_test.go | 2 +- plugins/inputs/disk/disk.go | 2 +- plugins/inputs/disk/disk_test.go | 2 +- plugins/inputs/diskio/diskio.go | 2 +- plugins/inputs/diskio/diskio_test.go | 2 +- .../inputs/intel_powerstat/intel_powerstat.go | 2 +- plugins/inputs/mem/mem_test.go | 2 +- plugins/inputs/net/net_test.go | 2 +- plugins/inputs/netstat/netstat_test.go | 2 +- plugins/inputs/procstat/filter.go | 2 +- plugins/inputs/procstat/native_finder.go | 2 +- plugins/inputs/procstat/os_linux.go | 4 ++-- plugins/inputs/procstat/os_others.go | 4 ++-- plugins/inputs/procstat/os_windows.go | 4 ++-- plugins/inputs/procstat/process.go | 4 ++-- plugins/inputs/procstat/procstat.go | 2 +- plugins/inputs/procstat/procstat_test.go | 2 +- plugins/inputs/procstat/service_finders.go | 2 +- plugins/inputs/swap/swap_test.go | 2 +- plugins/inputs/system/mock_PS.go | 16 ++++++++-------- plugins/inputs/system/ps.go | 8 ++++---- plugins/inputs/system/system.go | 6 +++--- plugins/inputs/system/system_test.go | 2 +- plugins/inputs/temp/temp_notlinux.go | 8 ++++---- plugins/inputs/temp/temp_test.go | 14 +++++++------- 30 files changed, 60 insertions(+), 53 deletions(-) diff --git a/docs/LICENSE_OF_DEPENDENCIES.md b/docs/LICENSE_OF_DEPENDENCIES.md index b0a54bd9d41dc..dbea075da5587 100644 --- a/docs/LICENSE_OF_DEPENDENCIES.md +++ b/docs/LICENSE_OF_DEPENDENCIES.md @@ -130,6 +130,7 @@ following works: - github.com/eapache/go-resiliency [MIT License](https://github.com/eapache/go-resiliency/blob/master/LICENSE) - github.com/eapache/go-xerial-snappy [MIT License](https://github.com/eapache/go-xerial-snappy/blob/master/LICENSE) - github.com/eapache/queue [MIT License](https://github.com/eapache/queue/blob/master/LICENSE) +- github.com/ebitengine/purego [Apache License 2.0](https://github.com/ebitengine/purego/blob/main/LICENSE) - github.com/eclipse/paho.golang [Eclipse Public License - v 2.0](https://github.com/eclipse/paho.golang/blob/master/LICENSE) - github.com/eclipse/paho.mqtt.golang [Eclipse Public License - v 2.0](https://github.com/eclipse/paho.mqtt.golang/blob/master/LICENSE) - github.com/emicklei/go-restful [MIT License](https://github.com/emicklei/go-restful/blob/v3/LICENSE) diff --git a/go.mod b/go.mod index 6712df31997a7..12cb2c290ca94 100644 --- a/go.mod +++ b/go.mod @@ -178,7 +178,7 @@ require ( github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/seancfoley/ipaddress-go v1.7.0 github.com/sensu/sensu-go/api/core/v2 v2.16.0 - github.com/shirou/gopsutil/v3 v3.24.4 + github.com/shirou/gopsutil/v4 v4.24.9 github.com/showwin/speedtest-go v1.7.9 github.com/signalfx/golib/v3 v3.3.54 github.com/sijms/go-ora/v2 v2.8.19 @@ -320,6 +320,7 @@ require ( github.com/eapache/go-resiliency v1.6.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect + github.com/ebitengine/purego v0.8.0 // indirect github.com/echlebek/timeproxy v1.0.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -449,6 +450,7 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/samber/lo v1.38.1 // indirect github.com/seancfoley/bintree v1.3.1 // indirect + github.com/shirou/gopsutil/v3 v3.24.4 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 // indirect diff --git a/go.sum b/go.sum index 23f9ed2e8e2d4..4986aa5ee7d25 100644 --- a/go.sum +++ b/go.sum @@ -1129,6 +1129,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE= +github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/echlebek/crock v1.0.1 h1:KbzamClMIfVIkkjq/GTXf+N16KylYBpiaTitO3f1ujg= github.com/echlebek/crock v1.0.1/go.mod h1:/kvwHRX3ZXHj/kHWJkjXDmzzRow54EJuHtQ/PapL/HI= github.com/echlebek/timeproxy v1.0.0 h1:V41/v8tmmMDNMA2GrBPI45nlXb3F7+OY+nJz1BqKsCk= @@ -2175,6 +2177,8 @@ github.com/sensu/sensu-go/api/core/v2 v2.16.0/go.mod h1:MjM7+MCGEyTAgaZ589SiGHwY github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil/v3 v3.24.4 h1:dEHgzZXt4LMNm+oYELpzl9YCqV65Yr/6SfrvgRBtXeU= github.com/shirou/gopsutil/v3 v3.24.4/go.mod h1:lTd2mdiOspcqLgAnr9/nGi71NkeMpWKdmhuxm9GusH8= +github.com/shirou/gopsutil/v4 v4.24.9 h1:KIV+/HaHD5ka5f570RZq+2SaeFsb/pq+fp2DGNWYoOI= +github.com/shirou/gopsutil/v4 v4.24.9/go.mod h1:3fkaHNeYsUFCGZ8+9vZVWtbyM1k2eRnlL+bWO8Bxa/Q= 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= diff --git a/plugins/inputs/conntrack/conntrack_test.go b/plugins/inputs/conntrack/conntrack_test.go index cfb4e99e6a171..a9a853457c1ae 100644 --- a/plugins/inputs/conntrack/conntrack_test.go +++ b/plugins/inputs/conntrack/conntrack_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/shirou/gopsutil/v3/net" + "github.com/shirou/gopsutil/v4/net" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf/plugins/inputs/system" diff --git a/plugins/inputs/cpu/cpu.go b/plugins/inputs/cpu/cpu.go index b1704e0023bb9..c2cb91c42c2d8 100644 --- a/plugins/inputs/cpu/cpu.go +++ b/plugins/inputs/cpu/cpu.go @@ -7,7 +7,7 @@ import ( "fmt" "time" - "github.com/shirou/gopsutil/v3/cpu" + "github.com/shirou/gopsutil/v4/cpu" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs" diff --git a/plugins/inputs/cpu/cpu_test.go b/plugins/inputs/cpu/cpu_test.go index 75f596356402f..030c97a51726b 100644 --- a/plugins/inputs/cpu/cpu_test.go +++ b/plugins/inputs/cpu/cpu_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/shirou/gopsutil/v3/cpu" + "github.com/shirou/gopsutil/v4/cpu" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf/plugins/inputs/system" diff --git a/plugins/inputs/disk/disk.go b/plugins/inputs/disk/disk.go index 2da391d83c80f..96c7a07859612 100644 --- a/plugins/inputs/disk/disk.go +++ b/plugins/inputs/disk/disk.go @@ -9,7 +9,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs/system" - "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v4/disk" ) //go:embed sample.conf diff --git a/plugins/inputs/disk/disk_test.go b/plugins/inputs/disk/disk_test.go index 877ce416fcd93..cb469a688eb17 100644 --- a/plugins/inputs/disk/disk_test.go +++ b/plugins/inputs/disk/disk_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v4/disk" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/plugins/inputs/diskio/diskio.go b/plugins/inputs/diskio/diskio.go index daf97ad1de31b..e5fee0dcaf8d8 100644 --- a/plugins/inputs/diskio/diskio.go +++ b/plugins/inputs/diskio/diskio.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v4/disk" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/filter" diff --git a/plugins/inputs/diskio/diskio_test.go b/plugins/inputs/diskio/diskio_test.go index 17dce11367223..0c8d0c6be71ab 100644 --- a/plugins/inputs/diskio/diskio_test.go +++ b/plugins/inputs/diskio/diskio_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v4/disk" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf/plugins/inputs/system" diff --git a/plugins/inputs/intel_powerstat/intel_powerstat.go b/plugins/inputs/intel_powerstat/intel_powerstat.go index 31a497cf563c6..c6d74f062ce97 100644 --- a/plugins/inputs/intel_powerstat/intel_powerstat.go +++ b/plugins/inputs/intel_powerstat/intel_powerstat.go @@ -14,7 +14,7 @@ import ( "time" "github.com/intel/powertelemetry" - "github.com/shirou/gopsutil/v3/cpu" + "github.com/shirou/gopsutil/v4/cpu" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" diff --git a/plugins/inputs/mem/mem_test.go b/plugins/inputs/mem/mem_test.go index 06561875753c9..ecf3a8cebc81c 100644 --- a/plugins/inputs/mem/mem_test.go +++ b/plugins/inputs/mem/mem_test.go @@ -7,7 +7,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs/system" "github.com/influxdata/telegraf/testutil" - "github.com/shirou/gopsutil/v3/mem" + "github.com/shirou/gopsutil/v4/mem" "github.com/stretchr/testify/require" ) diff --git a/plugins/inputs/net/net_test.go b/plugins/inputs/net/net_test.go index 7cdc9130e9b41..2f8ff0ae7dec5 100644 --- a/plugins/inputs/net/net_test.go +++ b/plugins/inputs/net/net_test.go @@ -9,7 +9,7 @@ import ( "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/plugins/inputs/system" "github.com/influxdata/telegraf/testutil" - "github.com/shirou/gopsutil/v3/net" + "github.com/shirou/gopsutil/v4/net" "github.com/stretchr/testify/require" ) diff --git a/plugins/inputs/netstat/netstat_test.go b/plugins/inputs/netstat/netstat_test.go index 8208beb3afbf5..05cc4b227eb44 100644 --- a/plugins/inputs/netstat/netstat_test.go +++ b/plugins/inputs/netstat/netstat_test.go @@ -9,7 +9,7 @@ import ( "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/plugins/inputs/system" "github.com/influxdata/telegraf/testutil" - "github.com/shirou/gopsutil/v3/net" + "github.com/shirou/gopsutil/v4/net" "github.com/stretchr/testify/require" ) diff --git a/plugins/inputs/procstat/filter.go b/plugins/inputs/procstat/filter.go index f7b89c12a811b..9efe37f4412f8 100644 --- a/plugins/inputs/procstat/filter.go +++ b/plugins/inputs/procstat/filter.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/process" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/filter" diff --git a/plugins/inputs/procstat/native_finder.go b/plugins/inputs/procstat/native_finder.go index eafbb9e0680e2..5f9812782b094 100644 --- a/plugins/inputs/procstat/native_finder.go +++ b/plugins/inputs/procstat/native_finder.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/process" ) // NativeFinder uses gopsutil to find processes diff --git a/plugins/inputs/procstat/os_linux.go b/plugins/inputs/procstat/os_linux.go index 22699fab123f1..a146f2c500afa 100644 --- a/plugins/inputs/procstat/os_linux.go +++ b/plugins/inputs/procstat/os_linux.go @@ -13,8 +13,8 @@ import ( "github.com/coreos/go-systemd/v22/dbus" "github.com/prometheus/procfs" - "github.com/shirou/gopsutil/v3/net" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/net" + "github.com/shirou/gopsutil/v4/process" "github.com/vishvananda/netlink" "golang.org/x/sys/unix" ) diff --git a/plugins/inputs/procstat/os_others.go b/plugins/inputs/procstat/os_others.go index f14671c1ffebb..62334f885ccda 100644 --- a/plugins/inputs/procstat/os_others.go +++ b/plugins/inputs/procstat/os_others.go @@ -6,8 +6,8 @@ import ( "errors" "syscall" - "github.com/shirou/gopsutil/v3/net" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/net" + "github.com/shirou/gopsutil/v4/process" ) func processName(p *process.Process) (string, error) { diff --git a/plugins/inputs/procstat/os_windows.go b/plugins/inputs/procstat/os_windows.go index d53c3da3b7276..05ada5a4748bc 100644 --- a/plugins/inputs/procstat/os_windows.go +++ b/plugins/inputs/procstat/os_windows.go @@ -8,8 +8,8 @@ import ( "syscall" "unsafe" - "github.com/shirou/gopsutil/v3/net" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/net" + "github.com/shirou/gopsutil/v4/process" "golang.org/x/sys/windows" "golang.org/x/sys/windows/svc/mgr" ) diff --git a/plugins/inputs/procstat/process.go b/plugins/inputs/procstat/process.go index 9cb100b75fa5a..a0e8e60c880f0 100644 --- a/plugins/inputs/procstat/process.go +++ b/plugins/inputs/procstat/process.go @@ -8,8 +8,8 @@ import ( "syscall" "time" - gopsnet "github.com/shirou/gopsutil/v3/net" - "github.com/shirou/gopsutil/v3/process" + gopsnet "github.com/shirou/gopsutil/v4/net" + "github.com/shirou/gopsutil/v4/process" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/metric" diff --git a/plugins/inputs/procstat/procstat.go b/plugins/inputs/procstat/procstat.go index bd9b4d8bd7d2c..6a50cb317ad2b 100644 --- a/plugins/inputs/procstat/procstat.go +++ b/plugins/inputs/procstat/procstat.go @@ -15,7 +15,7 @@ import ( "strings" "time" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/process" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal/choice" diff --git a/plugins/inputs/procstat/procstat_test.go b/plugins/inputs/procstat/procstat_test.go index 0a0fe2775c60f..d986aea317384 100644 --- a/plugins/inputs/procstat/procstat_test.go +++ b/plugins/inputs/procstat/procstat_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/process" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" diff --git a/plugins/inputs/procstat/service_finders.go b/plugins/inputs/procstat/service_finders.go index 50a0dc8bdfe11..169c64f70957c 100644 --- a/plugins/inputs/procstat/service_finders.go +++ b/plugins/inputs/procstat/service_finders.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/influxdata/telegraf" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/process" ) type processFinder struct { diff --git a/plugins/inputs/swap/swap_test.go b/plugins/inputs/swap/swap_test.go index 85a8adb5c184c..652cb56d39cd1 100644 --- a/plugins/inputs/swap/swap_test.go +++ b/plugins/inputs/swap/swap_test.go @@ -5,7 +5,7 @@ import ( "github.com/influxdata/telegraf/plugins/inputs/system" "github.com/influxdata/telegraf/testutil" - "github.com/shirou/gopsutil/v3/mem" + "github.com/shirou/gopsutil/v4/mem" "github.com/stretchr/testify/require" ) diff --git a/plugins/inputs/system/mock_PS.go b/plugins/inputs/system/mock_PS.go index 67f859156506f..51f766ab1a989 100644 --- a/plugins/inputs/system/mock_PS.go +++ b/plugins/inputs/system/mock_PS.go @@ -5,13 +5,13 @@ import ( "github.com/stretchr/testify/mock" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/disk" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/cpu" + "github.com/shirou/gopsutil/v4/disk" + "github.com/shirou/gopsutil/v4/sensors" - "github.com/shirou/gopsutil/v3/load" - "github.com/shirou/gopsutil/v3/mem" - "github.com/shirou/gopsutil/v3/net" + "github.com/shirou/gopsutil/v4/load" + "github.com/shirou/gopsutil/v4/mem" + "github.com/shirou/gopsutil/v4/net" ) type MockPS struct { @@ -101,10 +101,10 @@ func (m *MockPS) SwapStat() (*mem.SwapMemoryStat, error) { return r0, r1 } -func (m *MockPS) Temperature() ([]host.TemperatureStat, error) { +func (m *MockPS) Temperature() ([]sensors.TemperatureStat, error) { ret := m.Called() - r0 := ret.Get(0).([]host.TemperatureStat) + r0 := ret.Get(0).([]sensors.TemperatureStat) r1 := ret.Error(1) return r0, r1 diff --git a/plugins/inputs/system/ps.go b/plugins/inputs/system/ps.go index 0bca091e861f8..a8915838d2f80 100644 --- a/plugins/inputs/system/ps.go +++ b/plugins/inputs/system/ps.go @@ -6,10 +6,10 @@ import ( "path/filepath" "strings" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/disk" - "github.com/shirou/gopsutil/v3/mem" - "github.com/shirou/gopsutil/v3/net" + "github.com/shirou/gopsutil/v4/cpu" + "github.com/shirou/gopsutil/v4/disk" + "github.com/shirou/gopsutil/v4/mem" + "github.com/shirou/gopsutil/v4/net" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal" diff --git a/plugins/inputs/system/system.go b/plugins/inputs/system/system.go index 064ae09153b3a..d553b26e09876 100644 --- a/plugins/inputs/system/system.go +++ b/plugins/inputs/system/system.go @@ -10,9 +10,9 @@ import ( "strings" "time" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/host" - "github.com/shirou/gopsutil/v3/load" + "github.com/shirou/gopsutil/v4/cpu" + "github.com/shirou/gopsutil/v4/host" + "github.com/shirou/gopsutil/v4/load" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs" diff --git a/plugins/inputs/system/system_test.go b/plugins/inputs/system/system_test.go index 22a2ab66d6daf..52c7fcc6b03eb 100644 --- a/plugins/inputs/system/system_test.go +++ b/plugins/inputs/system/system_test.go @@ -3,7 +3,7 @@ package system import ( "testing" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/host" "github.com/stretchr/testify/require" ) diff --git a/plugins/inputs/temp/temp_notlinux.go b/plugins/inputs/temp/temp_notlinux.go index 6cd0b42517595..437efde87c7ba 100644 --- a/plugins/inputs/temp/temp_notlinux.go +++ b/plugins/inputs/temp/temp_notlinux.go @@ -8,7 +8,7 @@ import ( "fmt" "strings" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/sensors" "github.com/influxdata/telegraf" ) @@ -26,10 +26,10 @@ func (t *Temperature) Init() error { } func (t *Temperature) Gather(acc telegraf.Accumulator) error { - temps, err := host.SensorsTemperatures() + temps, err := sensors.SensorsTemperatures() if err != nil { - var hostWarnings *host.Warnings - if !errors.As(err, &hostWarnings) { + var sensorsWarnings *sensors.Warnings + if !errors.As(err, &sensorsWarnings) { if strings.Contains(err.Error(), "not implemented yet") { return fmt.Errorf("plugin is not supported on this platform: %w", err) } diff --git a/plugins/inputs/temp/temp_test.go b/plugins/inputs/temp/temp_test.go index b81eb786d905f..b990796459c35 100644 --- a/plugins/inputs/temp/temp_test.go +++ b/plugins/inputs/temp/temp_test.go @@ -11,7 +11,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/sensors" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" @@ -226,7 +226,7 @@ func TestRegression(t *testing.T) { // Use the v1.28.x code to compare against var acc testutil.Accumulator - temps, err := host.SensorsTemperatures() + temps, err := sensors.SensorsTemperatures() require.NoError(t, err) for _, temp := range temps { tags := map[string]string{ @@ -244,7 +244,7 @@ func TestRegression(t *testing.T) { } } -func sensorsTemperaturesOld(syspath string) ([]host.TemperatureStat, error) { +func sensorsTemperaturesOld(syspath string) ([]sensors.TemperatureStat, error) { files, err := filepath.Glob(syspath + "/class/hwmon/hwmon*/temp*_*") if err != nil { return nil, err @@ -264,7 +264,7 @@ func sensorsTemperaturesOld(syspath string) ([]host.TemperatureStat, error) { return nil, err } - temperatures := make([]host.TemperatureStat, 0, len(files)) + temperatures := make([]sensors.TemperatureStat, 0, len(files)) for _, file := range files { // Get the name of the temperature you are reading name, err := os.ReadFile(filepath.Join(file, "type")) @@ -284,7 +284,7 @@ func sensorsTemperaturesOld(syspath string) ([]host.TemperatureStat, error) { continue } - temperatures = append(temperatures, host.TemperatureStat{ + temperatures = append(temperatures, sensors.TemperatureStat{ SensorKey: strings.TrimSpace(string(name)), Temperature: float64(temperature) / 1000.0, }) @@ -298,7 +298,7 @@ func sensorsTemperaturesOld(syspath string) ([]host.TemperatureStat, error) { // power/ temp1_label temp2_label temp3_label temp4_label temp5_label temp6_label temp7_label // subsystem/ temp1_max temp2_max temp3_max temp4_max temp5_max temp6_max temp7_max // temp1_crit temp2_crit temp3_crit temp4_crit temp5_crit temp6_crit temp7_crit uevent - temperatures := make([]host.TemperatureStat, 0, len(files)) + temperatures := make([]sensors.TemperatureStat, 0, len(files)) for _, file := range files { filename := strings.Split(filepath.Base(file), "_") if filename[1] == "label" { @@ -335,7 +335,7 @@ func sensorsTemperaturesOld(syspath string) ([]host.TemperatureStat, error) { } tempName := strings.TrimSpace(strings.ToLower(strings.Join(filename[1:], ""))) - temperatures = append(temperatures, host.TemperatureStat{ + temperatures = append(temperatures, sensors.TemperatureStat{ SensorKey: fmt.Sprintf("%s_%s%s", strings.TrimSpace(string(name)), label, tempName), Temperature: temperature / 1000.0, })