Sha256: 4a21bca043d0c7aae490dc144e546d241fbd697722d2fcfb728933aa935bdb7d

Contents?: true

Size: 486 Bytes

Versions: 2

Compression:

Stored size: 486 Bytes

Contents

require "socket"
require "json"

module Healthety
  class Transmission
    def initialize(host, port)
      @host = host
      @port = port
      @worker_host = Socket.gethostname
      @socket = UDPSocket.new
    end

    def send(name, value)
      data = {
        :value => value,
        :name => name,
        :date => Time.now.to_f,
        :host => @worker_host
      }.to_json

      @socket.send(data, 0, @host, @port)
      $stdout << "#{name}: #{value}\n"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
healthety-0.0.7 lib/healthety/transmission.rb
healthety-0.0.6 lib/healthety/transmission.rb