Class: LogStash::Inputs::Pcap

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/pcap.rb

Overview

This plugin works into getting data from your networks into logstash by leveraing the libpcap capabilities in your OS.

Instance Method Summary collapse

Instance Method Details

#registerObject



19
20
21
22
# File 'lib/logstash/inputs/pcap.rb', line 19

def register
  require "pcap"
  @client = Jruby::Pcap.live(@interface)
end

#run(queue) ⇒ Object

def register



24
25
26
27
28
29
30
31
32
# File 'lib/logstash/inputs/pcap.rb', line 24

def run(queue)
  @client.each do |packet|
    payload = { :timestamp => packet.timestamp }
    payload.merge!(packet.to_hash)
    event = LogStash::Event.new(payload)
    decorate(event)
    queue << event
  end
end