Compare commits
No commits in common. "main" and "v0.4.0" have entirely different histories.
@ -49,7 +49,6 @@ Flags:
|
|||||||
--time int time in seconds to transmit for (default 5)
|
--time int time in seconds to transmit for (default 5)
|
||||||
--timeout duration scraping timeout (default 1m0s)
|
--timeout duration scraping timeout (default 1m0s)
|
||||||
-v, --version print version
|
-v, --version print version
|
||||||
--wait duration time to wait between download and upload runs (default 1s)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
@ -70,7 +69,6 @@ colors = false # disable colors. this is only usable if log.json is set to false
|
|||||||
|
|
||||||
[iperf3] # straight up iperf3 command line flag options
|
[iperf3] # straight up iperf3 command line flag options
|
||||||
time = 10 # this sets the --time flag of iperf3 to 10
|
time = 10 # this sets the --time flag of iperf3 to 10
|
||||||
wait = "10s" # wait time between download and upload scrape
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Environment variables
|
#### Environment variables
|
||||||
|
15
main.go
15
main.go
@ -57,8 +57,7 @@ type config struct {
|
|||||||
Colors bool `validate:"required"`
|
Colors bool `validate:"required"`
|
||||||
}
|
}
|
||||||
Iperf3 struct {
|
Iperf3 struct {
|
||||||
Time int `validate:"required"`
|
Time int `validate:"required"`
|
||||||
Wait time.Duration `validation:"required,min=1ms"`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,20 +268,15 @@ func probeHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
logger.Info().Msg("getting download metrics")
|
logger.Info().Msg("getting download metrics")
|
||||||
|
|
||||||
if err := download(ctx, t, logger); err != nil {
|
if err := download(ctx, t, logger); err != nil {
|
||||||
scrapeErrors.Inc()
|
|
||||||
logger.Error().Err(err).Msg("could not create download metrics")
|
logger.Error().Err(err).Msg("could not create download metrics")
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug().Dur("wait", c.Iperf3.Wait).Msg("waiting")
|
|
||||||
time.Sleep(c.Iperf3.Wait)
|
|
||||||
|
|
||||||
logger.Info().Msg("getting upload metrics")
|
logger.Info().Msg("getting upload metrics")
|
||||||
|
|
||||||
if err := upload(ctx, t, logger); err != nil {
|
if err := upload(ctx, t, logger); err != nil {
|
||||||
scrapeErrors.Inc()
|
|
||||||
logger.Error().Err(err).Msg("could not create upload metrics")
|
logger.Error().Err(err).Msg("could not create upload metrics")
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
||||||
@ -356,13 +350,6 @@ func init() { //nolint:gochecknoinits,funlen
|
|||||||
}
|
}
|
||||||
|
|
||||||
viper.SetDefault("iperf3.time", 5) //nolint:gomnd
|
viper.SetDefault("iperf3.time", 5) //nolint:gomnd
|
||||||
|
|
||||||
// IPerf3.Wait.
|
|
||||||
rootCmd.PersistentFlags().Duration("wait", time.Second, "time to wait between download and upload runs")
|
|
||||||
|
|
||||||
if err := viper.BindPFlag("iperf3.wait", rootCmd.PersistentFlags().Lookup("wait")); err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("could not bind flag")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initConfig() {
|
func initConfig() {
|
||||||
|
Loading…
Reference in New Issue
Block a user