Class: SflowCollector
- Inherits:
-
Object
- Object
- SflowCollector
- Defined in:
- lib/sflow/lib/sflow/collector.rb
Defined Under Namespace
Modules: Collector
Class Method Summary collapse
Class Method Details
.start_collector(bind_ip = '0.0.0.0', bind_port = 6343) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sflow/lib/sflow/collector.rb', line 41 def self.start_collector(bind_ip = '0.0.0.0', bind_port = 6343) begin config = SflowConfig.new if config.logstash_host and config.logstash_port puts "Connecting to Logstash: #{config.logstash_host}:#{config.logstash_port}" $logstash = UDPSocket.new $logstash.connect(config.logstash_host, config.logstash_port) else puts "no host:port given" exit 1 end $switch_hash = config.switch_hash if config.switch_hash != nil $switchportnames = SNMPwalk.new(config.switch_hash.each_key) end EventMachine::run do EventMachine::open_datagram_socket(bind_ip, bind_port, Collector) end rescue Exception => e puts Time.now puts e. puts e.backtrace raise "unable to start sflow collector" end end |