Sha256: 060c88d4a980c5b402271d9c2747551388281fafeb89eb800476b41f998752e5
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
require 'tailstrom/counter' require 'tailstrom/table' require 'tailstrom/tail_reader' module Tailstrom module Command class Stat SCHEMA = [ { :name => 'count', :width => 7 }, { :name => 'min', :width => 15 }, { :name => 'max', :width => 15 }, { :name => 'avg', :width => 15 } ] def initialize(options) @infile = $stdin @counter = Counter.new @table = Table.new SCHEMA @options = options end def run Thread.start do reader = TailReader.new @infile, @options reader.each_line do |line| @counter << line[:value] end end @table.print_header loop do if @counter @table.print_row( @counter.count, @counter.min, @counter.max, @counter.avg ) end @counter.clear sleep @options[:interval] end rescue Interrupt exit 0 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tailstrom-0.0.3 | lib/tailstrom/command/stat.rb |
tailstrom-0.0.2 | lib/tailstrom/command/stat.rb |