Permalink
Browse files

Update varnish plugin to solve NaN hitrate issue

In the case where there is no varnish activity at all, the total will be zero and the hitrate will be 0 / 0, which produces 'NaN' in javascript which breaks scout.
  • Loading branch information...
1 parent 56b0666 commit 28f4e48efe2ab0f6a8689021d28c11758351f40d @mnutt mnutt committed Sep 12, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 varnish/varnish.rb
View
@@ -28,7 +28,7 @@ def build_report
end
total = stats[:cache_miss] + stats[:cache_hit] + stats[:cache_hitpass]
- hitrate = stats[:cache_hit].to_f / total * 100
+ hitrate = stats[:cache_hit].to_f / (total.nonzero? || 1) * 100
report(:hitrate => hitrate)
option(:metrics).split(/,\s*/).compact.each do |metric|

0 comments on commit 28f4e48

Please sign in to comment.