Class: EventMachine::SFlow::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/em-sflow/collector.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Collector

Returns a new instance of Collector.



5
6
7
8
9
10
11
12
13
# File 'lib/em-sflow/collector.rb', line 5

def initialize args = {}
  args[:host] ||= "127.0.0.1"
  args[:port] ||= 6343
  
  @callbacks = []
  @proxy_targets = []
  
  EventMachine.open_datagram_socket(args[:host], args[:port], DatagramHandler, {:host => args[:host], :callbacks => @callbacks, :proxy_targets => @proxy_targets})
end

Instance Method Details

#on_sflow(&proc) ⇒ Object



19
20
21
# File 'lib/em-sflow/collector.rb', line 19

def on_sflow &proc
  @callbacks << proc
end

#proxy_to(target) ⇒ Object



15
16
17
# File 'lib/em-sflow/collector.rb', line 15

def proxy_to target
  @proxy_targets << target
end