Skip to content

Commit

Permalink
fix: internet_speed input plugin not collecting/reporting latency (#9957
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ersanyamarya authored Oct 19, 2021
1 parent 81cc2ef commit 62d5f63
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/inputs/internet_speed/internet_speed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internet_speed

import (
"fmt"
"time"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
Expand Down Expand Up @@ -68,7 +69,7 @@ func (is *InternetSpeed) Gather(acc telegraf.Accumulator) error {
fields := make(map[string]interface{})
fields["download"] = s.DLSpeed
fields["upload"] = s.ULSpeed
fields["latency"] = s.Latency
fields["latency"] = timeDurationMillisecondToFloat64(s.Latency)

tags := make(map[string]string)

Expand All @@ -80,3 +81,7 @@ func init() {
return &InternetSpeed{}
})
}

func timeDurationMillisecondToFloat64(d time.Duration) float64 {
return float64(d) / float64(time.Millisecond)
}

0 comments on commit 62d5f63

Please sign in to comment.