From 37351b9dd0adeda6d68b73eb1b0a5bc853819c9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:37 +0100 Subject: [PATCH] chore(deps): Bump github.com/showwin/speedtest-go from 1.6.6 to 1.6.7 (#14250) Co-authored-by: Josh Powers Co-authored-by: r3inbowari (cherry picked from commit d644ffd3d2a7b3103b9d18a4c570fb92d0e81adf) --- go.mod | 2 +- go.sum | 4 ++-- plugins/inputs/internet_speed/internet_speed.go | 7 ++++++- plugins/inputs/internet_speed/internet_speed_test.go | 10 +++------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index b001677c5ef49..65fcf6fe8e472 100644 --- a/go.mod +++ b/go.mod @@ -163,7 +163,7 @@ require ( github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/sensu/sensu-go/api/core/v2 v2.16.0 github.com/shirou/gopsutil/v3 v3.23.9 - github.com/showwin/speedtest-go v1.6.6 + github.com/showwin/speedtest-go v1.6.7 github.com/signalfx/golib/v3 v3.3.53 github.com/sirupsen/logrus v1.9.3 github.com/sleepinggenius2/gosmi v0.4.4 diff --git a/go.sum b/go.sum index e28ec4e2cfbd8..72bc2800a21bf 100644 --- a/go.sum +++ b/go.sum @@ -2074,8 +2074,8 @@ github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9Nz github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/showwin/speedtest-go v1.6.6 h1:WPq8vhD1aHzt23hJA+wHe3MLOXsVrMMOjU2UO98pOSc= -github.com/showwin/speedtest-go v1.6.6/go.mod h1:uLgdWCNarXxlYsL2E5TOZpCIwpgSWnEANZp7gfHXHu0= +github.com/showwin/speedtest-go v1.6.7 h1:U0uMD9v4QS2JEqBoCHPWYQ1S9f87AnSSl5WsT+sBX6c= +github.com/showwin/speedtest-go v1.6.7/go.mod h1:uLgdWCNarXxlYsL2E5TOZpCIwpgSWnEANZp7gfHXHu0= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 h1:32k2QLgsKhcEs55q4REPKyIadvid5FPy2+VMgvbmKJ0= github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3/go.mod h1:gJrXWi7wSGXfiC7+VheQaz+ypdCt5SmZNL+BRxUe7y4= diff --git a/plugins/inputs/internet_speed/internet_speed.go b/plugins/inputs/internet_speed/internet_speed.go index bf8706c258110..a28c04b0afe3c 100644 --- a/plugins/inputs/internet_speed/internet_speed.go +++ b/plugins/inputs/internet_speed/internet_speed.go @@ -121,9 +121,14 @@ func (is *InternetSpeed) Gather(acc telegraf.Accumulator) error { } func (is *InternetSpeed) findClosestServer() error { + proto := speedtest.HTTP + if os.Getegid() <= 0 { + proto = speedtest.ICMP + } + client := speedtest.New(speedtest.WithUserConfig(&speedtest.UserConfig{ UserAgent: internal.ProductToken(), - ICMP: os.Geteuid() == 0 || os.Geteuid() == -1, + PingMode: proto, SavingMode: is.MemorySavingMode, })) if is.Connections > 0 { diff --git a/plugins/inputs/internet_speed/internet_speed_test.go b/plugins/inputs/internet_speed/internet_speed_test.go index 4dbafe3731b01..2549a3c0b2fe4 100644 --- a/plugins/inputs/internet_speed/internet_speed_test.go +++ b/plugins/inputs/internet_speed/internet_speed_test.go @@ -15,9 +15,9 @@ func TestGathering(t *testing.T) { MemorySavingMode: true, Log: testutil.Logger{}, } + require.NoError(t, internetSpeed.Init()) acc := &testutil.Accumulator{} - require.NoError(t, internetSpeed.Gather(acc)) } @@ -29,16 +29,12 @@ func TestDataGen(t *testing.T) { MemorySavingMode: true, Log: testutil.Logger{}, } + require.NoError(t, internetSpeed.Init()) acc := &testutil.Accumulator{} require.NoError(t, internetSpeed.Gather(acc)) metric, ok := acc.Get("internet_speed") require.True(t, ok) - - tags := metric.Tags - - fields := metric.Fields - - acc.AssertContainsTaggedFields(t, "internet_speed", fields, tags) + acc.AssertContainsTaggedFields(t, "internet_speed", metric.Fields, metric.Tags) }