Sha256: e88229efac6ff9746ed34630a464c5c3d395f2d0d5168eed41e7783f57713dfe

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'fluent/plugin/input'

require 'bindata'
require 'eventmachine'
require 'yaml'

dir = 'sflow/lib/sflow'
['models/ipv4header', 'models/tcpheader', 'models/udpheader', 'models/protocol', 'models/binary_models','parsers/parsers'].each do |req|
  require File.join(dir, req)
end

#$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'sflow', 'lib'))
#require 'sflow'

module Fluent::Plugin
  class SflowInput < Input
    Fluent::Plugin.register_input("sflow", self)

    helpers :server

    config_param :bind, :string, default: '0.0.0.0'
    config_param :port, :integer, default: 6343
    config_param :tag, :string

    def configure(conf)
      super

      # dummy data
      $switch_hash = {}
    end

    def start
      super

      server_create(:in_sflow_server, @port, bind: @bind, proto: :udp, max_bytes: 2048) do |data, sock|
        sflow = SflowParser.parse_packet(data)
        router.emit(@tag, Fluent::EventTime.now, sflow)
      end
    end

    def shutdown
      super
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-sflow-0.1.0 lib/fluent/plugin/in_sflow.rb