fix(inputs.internet_speed): rename enable_file_download to match upstream intent (#11877)
This commit is contained in:
parent
e292ad2b4c
commit
2d124a4dbe
|
|
@ -3,6 +3,13 @@
|
|||
The `Internet Speed Monitor` collects data about the internet speed on the
|
||||
system.
|
||||
|
||||
On some systems, the default settings may cause speed tests to fail; if this
|
||||
affects you then try enabling `memory_saving_mode`. This reduces the memory
|
||||
requirements for the test, and may reduce the runtime of the test. However,
|
||||
please be aware that this may also reduce the accuracy of the test for fast
|
||||
(>30Mb/s) connections. This setting enables the upstream
|
||||
[Memory Saving Mode](https://github.com/showwin/speedtest-go#memory-saving-mode)
|
||||
|
||||
## Configuration
|
||||
|
||||
```toml @sample.conf
|
||||
|
|
@ -13,8 +20,8 @@ system.
|
|||
## demand on your internet connection.
|
||||
# interval = "60m"
|
||||
|
||||
## Sets if runs file download test
|
||||
# enable_file_download = false
|
||||
## Enable to reduce memory usage
|
||||
# memory_saving_mode = false
|
||||
|
||||
## Caches the closest server location
|
||||
# cache = false
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ var sampleConfig string
|
|||
|
||||
// InternetSpeed is used to store configuration values.
|
||||
type InternetSpeed struct {
|
||||
EnableFileDownload bool `toml:"enable_file_download"`
|
||||
EnableFileDownload bool `toml:"enable_file_download" deprecated:"1.25.0;use 'memory_saving_mode' instead"`
|
||||
MemorySavingMode bool `toml:"memory_saving_mode"`
|
||||
Cache bool `toml:"cache"`
|
||||
Log telegraf.Logger `toml:"-"`
|
||||
serverCache *speedtest.Server
|
||||
|
|
@ -29,6 +30,12 @@ func (*InternetSpeed) SampleConfig() string {
|
|||
return sampleConfig
|
||||
}
|
||||
|
||||
func (is *InternetSpeed) Init() error {
|
||||
is.MemorySavingMode = is.MemorySavingMode || is.EnableFileDownload
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (is *InternetSpeed) Gather(acc telegraf.Accumulator) error {
|
||||
// Get closest server
|
||||
s := is.serverCache
|
||||
|
|
@ -58,13 +65,15 @@ func (is *InternetSpeed) Gather(acc telegraf.Accumulator) error {
|
|||
return fmt.Errorf("ping test failed: %v", err)
|
||||
}
|
||||
is.Log.Debug("Running Download...")
|
||||
err = s.DownloadTest(is.EnableFileDownload)
|
||||
err = s.DownloadTest(is.MemorySavingMode)
|
||||
if err != nil {
|
||||
is.Log.Debug("try `memory_saving_mode = true` if this fails consistently")
|
||||
return fmt.Errorf("download test failed: %v", err)
|
||||
}
|
||||
is.Log.Debug("Running Upload...")
|
||||
err = s.UploadTest(is.EnableFileDownload)
|
||||
err = s.UploadTest(is.MemorySavingMode)
|
||||
if err != nil {
|
||||
is.Log.Debug("try `memory_saving_mode = true` if this fails consistently")
|
||||
return fmt.Errorf("upload test failed failed: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ func TestGathering(t *testing.T) {
|
|||
t.Skip("Skipping network-dependent test in short mode.")
|
||||
}
|
||||
internetSpeed := &InternetSpeed{
|
||||
EnableFileDownload: true,
|
||||
Log: testutil.Logger{},
|
||||
MemorySavingMode: true,
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
||||
acc := &testutil.Accumulator{}
|
||||
|
|
@ -26,8 +26,8 @@ func TestDataGen(t *testing.T) {
|
|||
t.Skip("Skipping network-dependent test in short mode.")
|
||||
}
|
||||
internetSpeed := &InternetSpeed{
|
||||
EnableFileDownload: true,
|
||||
Log: testutil.Logger{},
|
||||
MemorySavingMode: true,
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
||||
acc := &testutil.Accumulator{}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
## demand on your internet connection.
|
||||
# interval = "60m"
|
||||
|
||||
## Sets if runs file download test
|
||||
# enable_file_download = false
|
||||
## Enable to reduce memory usage
|
||||
# memory_saving_mode = false
|
||||
|
||||
## Caches the closest server location
|
||||
# cache = false
|
||||
|
|
|
|||
Loading…
Reference in New Issue