Sha256: 29f63e6aa76fcaffe490e03c74b8fa579642d90cd612bdd9b6ab0149fd753ce5

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

require 'socket'
require 'thread'

module Collectd
  class Server < Values

    def initialize(interval, host, port)
      super(interval)
      @sock = UDPSocket.new(host.index(':') ? Socket::AF_INET6 : Socket::AF_INET)
      @sock.connect(host, port)

      Thread.new do
        loop do
          sleep interval

          Collectd.run_pollables_for self
          pkt = make_pkt
          begin
            @sock.send(pkt, 0)
          rescue SystemCallError
          end
        end
      end.abort_on_exception = true
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
collectd-0.0.15 lib/collectd/server.rb