diff --git a/go.mod b/go.mod index 0d8c4ae2..0a292b03 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/hunterlong/apizer +module github.com/hunterlong/statup require ( github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da @@ -8,4 +8,5 @@ require ( github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 github.com/lib/pq v0.0.0-20180523175426-90697d60dd84 golang.org/x/crypto v0.0.0-20180608092829-8ac0e0d97ce4 + gopkg.in/check.v1 v1.0.0-20161208181325-20d25e280405 ) diff --git a/services.go b/services.go index c618de9f..81242c4c 100644 --- a/services.go +++ b/services.go @@ -86,6 +86,10 @@ func (s *Service) Online24() float64 { s.Online24Hours = 100.00 return s.Online24Hours } + if total == 0 { + s.Online24Hours = 0 + return s.Online24Hours + } avg := float64(failed) / float64(total) * 100 s.Online24Hours = avg return avg @@ -119,6 +123,10 @@ func (s *Service) AvgUptime() float64 { s.TotalUptime = 100.00 return s.TotalUptime } + if total == 0 { + s.TotalUptime = 0 + return s.TotalUptime + } percent := float64(failed) / float64(total) * 100 s.TotalUptime = percent return percent