Sha256: a82ca4c8c178a9ad130c6e5d44730290c25bc1e49639fd2dca6f4a6816a2eedc

Contents?: true

Size: 611 Bytes

Versions: 3

Compression:

Stored size: 611 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
          begin
            @sock.send(pkt, 0)
          rescue SystemCallError
          end
        end
      end.abort_on_exception = true
    end

  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
astro-collectd-0.0.11 lib/collectd/server.rb
astro-collectd-0.0.12 lib/collectd/server.rb
collectd-0.0.12 lib/collectd/server.rb