Class: Collectd::EmServer
Instance Attribute Summary
Attributes inherited from Values
Instance Method Summary collapse
-
#initialize(interval, host, port) ⇒ EmServer
constructor
A new instance of EmServer.
Methods inherited from Values
#inc_counter, #make_pkt, #set_counter, #set_gauge
Constructor Details
#initialize(interval, host, port) ⇒ EmServer
Returns a new instance of EmServer.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/collectd/em_server.rb', line 6 def initialize(interval, host, port) super(interval) @sock = UDPSocket.new(host.index(':') ? Socket::AF_INET6 : Socket::AF_INET) @sock.connect(host, port) EM.add_periodic_timer(interval) do Collectd.run_pollables_for self Thread.critical = true pkt = make_pkt Thread.critical = false @sock.send(pkt, 0) end end |