fix: internet_speed input plugin not collecting/reporting latency (#9957)
This commit is contained in:
parent
81cc2ef197
commit
62d5f635bb
|
|
@ -2,6 +2,7 @@ package internet_speed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
|
@ -68,7 +69,7 @@ func (is *InternetSpeed) Gather(acc telegraf.Accumulator) error {
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
fields["download"] = s.DLSpeed
|
fields["download"] = s.DLSpeed
|
||||||
fields["upload"] = s.ULSpeed
|
fields["upload"] = s.ULSpeed
|
||||||
fields["latency"] = s.Latency
|
fields["latency"] = timeDurationMillisecondToFloat64(s.Latency)
|
||||||
|
|
||||||
tags := make(map[string]string)
|
tags := make(map[string]string)
|
||||||
|
|
||||||
|
|
@ -80,3 +81,7 @@ func init() {
|
||||||
return &InternetSpeed{}
|
return &InternetSpeed{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func timeDurationMillisecondToFloat64(d time.Duration) float64 {
|
||||||
|
return float64(d) / float64(time.Millisecond)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue