Sha256: 106ee8661fce4d07eafae3af4e553b92adf7da10e2111b92526b969c8beb657f

Contents?: true

Size: 529 Bytes

Versions: 2

Compression:

Stored size: 529 Bytes

Contents

require 'fluent/parser'
require 'json'
require 'sflowtool'


module Fluent
  class TextParser
    class SflowParser < Parser
      Plugin.register_parser('sflow', self)


      def parse(raw, remote_host)
        data = JSON.load(Sflowtool.parse(raw, remote_host))

        # NOTE: sFlow datagram doesn't have timestamp field, but sysUpTime only
        time = data['header']['unix_seconds_utc']

        data['samples'].each do |sample|
          yield time, data['header'].merge(sample)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-sflow-0.2.1 lib/fluent/plugin/parser_sflow.rb
fluent-plugin-sflow-0.2.0 lib/fluent/plugin/parser_sflow.rb