Sha256: 03e784bb0d4a810f40e31e2423c70c13e079703785ec6f20b81cda0d5f64d33f
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
require 'logger' require 'tempfile' require 'jrjackson' require_relative 'mjolnir' require_relative 'metadata' require_relative 'stats' require_relative 'input' require_relative 'filter' require_relative 'output' module Anschel class Main < Mjolnir desc 'version', 'Show application version' def version puts VERSION end desc 'art', 'Show application art' def art puts "\n%s\n" % ART end desc 'agent', 'Run application' option :config, \ type: :string, aliases: %w[ -c ], desc: 'Path to primary configuration file', default: '/etc/anschel.json' option :stats_interval, \ type: :numeric, aliases: %w[ -i ], desc: 'Interval for reporting stats (seconds)', default: 30 include_common_options def agent log.info \ event: 'hello', version: VERSION, options: options.to_hash, num_cpus: num_cpus config = JrJackson::Json.load File.read(options.config), symbolize_keys: true setup_log4j config[:log4j] stats = Stats.new log, options.stats_interval input = Input.new config[:kafka], stats, log filter = Filter.new config[:filter], stats, log output = if config[:device] Output::Device.new config[:device], stats, log else Output::Elasticsearch.new config[:elasticsearch], stats, log end stats.create 'event' stats.get 'event' ts = num_cpus.times.map do Thread.new do loop do event = JrJackson::Json.load \ input.shift.message.to_s, symbolize_keys: true output.push filter.apply(event) stats.inc 'event' end end end log.info event: 'fully-loaded' ts.map &:join exit end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
anschel-0.4.1 | lib/anschel/main.rb |
anschel-0.4.0 | lib/anschel/main.rb |