Skip to content

Commit

Permalink
fix not to output percentage for zero counts
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Feb 22, 2012
1 parent 716792f commit 224e64b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/fluent/plugin/out_datacounter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def generate_output(counts, step)
name = @patterns[i][1]
output[name + '_count'] = count
output[name + '_rate'] = ((count * 100.0) / (1.00 * step)).floor / 100.0
output[name + '_percentage'] = count * 100.0 / (1.00 * sum)
output[name + '_percentage'] = count * 100.0 / (1.00 * sum) if sum > 1
end
return output
end
Expand All @@ -120,7 +120,7 @@ def generate_output(counts, step)
name = @patterns[i][1]
output[t + '_' + name + '_count'] = count
output[t + '_' + name + '_rate'] = ((count * 100.0) / (1.00 * step)).floor / 100.0
output[t + '_' + name + '_percentage'] = count * 100.0 / (1.00 * sum)
output[t + '_' + name + '_percentage'] = count * 100.0 / (1.00 * sum) if sum > 1
end
end
output
Expand Down

0 comments on commit 224e64b

Please sign in to comment.