lib/healthety/transmission.rb in healthety-0.0.5 vs lib/healthety/transmission.rb in healthety-0.0.6

- old
+ new

@@ -1,22 +1,25 @@ require "socket" require "json" module Healthety class Transmission - def initialize(server, port) - @server = server + def initialize(host, port) + @host = host @port = port - @host = Socket.gethostname + @worker_host = Socket.gethostname @socket = UDPSocket.new end - def send(name, value, created_at) + def send(name, value) data = { - :name => name, :value => value, - :created_at => created_at, :host => @host + :value => value, + :name => name, + :date => Time.now.to_f, + :host => @worker_host }.to_json - @socket.send(data, 0, @server, @port) + + @socket.send(data, 0, @host, @port) $stdout << "#{name}: #{value}\n" end end end