Skip to content

Commit

Permalink
[metricbeat] Add divide by zero check to docker/diskio (#15649) (#15706)
Browse files Browse the repository at this point in the history
* add NaN check to docker/diskio

* return 0

(cherry picked from commit c7e137c)
  • Loading branch information
fearful-symmetry authored May 8, 2020
1 parent c2f0236 commit 8589243
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion metricbeat/module/docker/diskio/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,11 @@ func calculatePerSecond(duration time.Duration, old uint64, new uint64) float64
if value < 0 {
value = 0
}
return value / duration.Seconds()

timeSec := duration.Seconds()
if timeSec == 0 {
return 0
}

return value / timeSec
}

0 comments on commit 8589243

Please sign in to comment.