Skip to content

Commit

Permalink
Merge pull request #65 from mcktr/bugfix/usage-calculation2
Browse files Browse the repository at this point in the history
Fix dividing by zero
  • Loading branch information
mcktr authored Sep 19, 2019
2 parents ce9e69a + 3d5db02 commit 8c329c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/check_fritz/check_downstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ func CheckDownstreamUsage(aI ArgumentInformation) {

downstreamCurrent = downstreamCurrent * 8 / 1000000
downstreamMax = downstreamMax * 8 / 1000000

if downstreamMax == 0 {
fmt.Printf("UNKNOWN - Maximum Downstream is 0\n")
return
}

downstreamUsage := 100 / downstreamMax * downstreamCurrent
perfData := perfdata.CreatePerformanceData("downstream_usage", downstreamUsage, "")

Expand Down
6 changes: 6 additions & 0 deletions cmd/check_fritz/check_upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ func CheckUpstreamUsage(aI ArgumentInformation) {

upstreamCurrent = upstreamCurrent * 8 / 1000000
upstreamMax = upstreamMax * 8 / 1000000

if upstreamMax == 0 {
fmt.Printf("UNKNOWN - Maximum Downstream is 0\n")
return
}

upstreamUsage := 100 / upstreamMax * upstreamCurrent
perfData := perfdata.CreatePerformanceData("upstream_usage", upstreamUsage, "")

Expand Down

0 comments on commit 8c329c4

Please sign in to comment.