Sha256: 3ba4e6097ad67e0d140b5cba61bddd7935467ecf65a74591c47b3e14be34432a

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 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
          Thread.critical = true
          pkt = make_pkt
          Thread.critical = false
          @sock.send(pkt, 0)
        end
      end.abort_on_exception = true
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
astro-collectd-0.0.10 lib/collectd/server.rb