From 77d8892a46a6d38d1a99aab1734980800ac44d56 Mon Sep 17 00:00:00 2001 From: nordicdyno Date: Sun, 18 Jan 2015 01:03:40 +0300 Subject: [PATCH] nsq_stat: fix 'division by zero' error for intervals less than 1s --- apps/nsq_stat/nsq_stat.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/nsq_stat/nsq_stat.go b/apps/nsq_stat/nsq_stat.go index 338c8997c..3bf3e63e7 100644 --- a/apps/nsq_stat/nsq_stat.go +++ b/apps/nsq_stat/nsq_stat.go @@ -102,8 +102,8 @@ func statLoop(interval time.Duration, topic string, channel string, // TODO: paused fmt.Printf("%7d %7d | %7d %7d %7d %5d %5d | %7d %7d %12d %7d\n", - (c.MessageCount-o.MessageCount)/int64(interval.Seconds()), - (c.MessageCount-o.MessageCount-(c.Depth-o.Depth))/int64(interval.Seconds()), + int64(float64(c.MessageCount-o.MessageCount)/interval.Seconds()), + int64(float64(c.MessageCount-o.MessageCount-(c.Depth-o.Depth))/interval.Seconds()), c.Depth, c.MemoryDepth, c.BackendDepth,