Module: Batsd::Statistics

Defined in:
lib/batsd/statistics.rb

Overview

Track and report statistics about the server and all of it's handlers

Instance Method Summary (collapse)

Instance Method Details

- (Object) receive_data(msg)

Handle an incoming message on port+1. Valid commands are 'stats', 'exit', and 'quit'.

Statistics are returned over JSON



10
11
12
13
14
15
16
17
18
19
# File 'lib/batsd/statistics.rb', line 10

def receive_data(msg)
  if msg.match /stats/
    stats = {}
    Batsd::Receiver.handlers.each{|type, handler| stats[type] =  handler.statistics }
    send_data "#{stats.to_json}\n"
  elsif msg.match /quit|exit/
    send_data "BYE\n"
    close_connection
  end
end