- Move LogStash::Components::Agent to LogStash::Agent

This commit is contained in:
Jordan Sissel 2010-10-18 00:26:02 +00:00
parent 4c38c9d8fe
commit ae50ca1d82
5 changed files with 22 additions and 56 deletions

View file

@ -2,7 +2,7 @@
require "rubygems"
require "eventmachine"
require "lib/components/agent"
require "logstash/agent"
case ARGV[0]
when "client"
@ -14,6 +14,7 @@ when "client"
"output" => [
"amqp://localhost/topic/testing",
"websocket:///",
"mongodb://localhost/testdb",
],
}
when "server"
@ -29,7 +30,23 @@ when "server"
"amqp://localhost/topic/parsed",
],
}
when "standalone"
config = {
"input" => [
"/var/log/messages",
"/var/log/apache2/access.log",
],
"filter" => [
"grok",
],
"output" => [
"mongodb://localhost/testdb",
],
}
else
puts "Don't know what you want me to do."
exit 1
end
agent = LogStash::Components::Agent.new(config)
agent = LogStash::Agent.new(config)
agent.run

View file

@ -4,11 +4,10 @@
# % logger -t "pantscon" "naughty host 14.33.24.55 $RANDOM"
require "rubygems"
require "eventmachine"
require "lib/components/agent"
require "logstash/agent"
require "ap"
class MyAgent < LogStash::Components::Agent
class MyAgent < LogStash::Agent
def receive(event)
filter(event) # Invoke any filters

View file

@ -6,7 +6,7 @@ require "logstash/outputs"
require "logstash/filters"
# Collect logs, ship them out.
class LogStash::Components::Agent
class LogStash::Agent
attr_reader :config
def initialize(config)

View file

@ -1,6 +1,5 @@
module LogStash
module Components; end
module Inputs; end
module Outputs; end
module Filters; end

View file

@ -1,49 +0,0 @@
class TrackingMutex < Mutex
def synchronize(&blk)
#puts "Enter #{self} @ #{Thread.current} + #{caller[0]}"
super { blk.call }
#puts "Exit #{self} @ #{Thread.current} + #{caller[0]}"
end # def synchronize
end # clas TrackingMutex < Mutex
module LogStash
class Util
def self.collapse(hash)
hash.each do |k, v|
if v.is_a?(Hash)
hash.delete(k)
collapse(v).each do |k2, v2|
hash["#{k}/#{k2}"] = v2
end
elsif v.is_a?(Array)
# do nothing; ferret can handle this
elsif not v.is_a?(String)
hash[k] = v.to_s
end
end
return hash
end # def self.collapse
end # class Util
class StopWatch
def initialize
start
end # def initialize
def start
@start = Time.now
end # def start
def duration
return Time.now - @start
end # def duration
def to_s(precision=-1)
# precision is for numbers, and '.' isn't a number, so pad for '.' if we
# want >0 precision
precision += 1 if precision > 0
return duration.to_s[0 .. precision]
end # def to_s
end # class StopWatch
end # module LogStash