class LogStash::Inputs::Yasuri
Public Instance Methods
inner_run(queue)
click to toggle source
# File lib/logstash/inputs/yasuri.rb, line 66 def inner_run(queue) parsed = scrape() elements = if @split parsed.flatten else [parsed] end elements.each do |e| event = LogStash::Event.new("parsed" => e, "host" => @host, "url" => @url) decorate(event) queue << event end end
register()
click to toggle source
# File lib/logstash/inputs/yasuri.rb, line 33 def register @host = Socket.gethostname @agent = Mechanize.new @scheduler = Rufus::Scheduler.new # If given both, logstash-input-yasuri use :parse_tree. tree = @parse_tree || File.read(@parse_tree_path) @tree = Yasuri.json2tree(tree) end
run(queue)
click to toggle source
# File lib/logstash/inputs/yasuri.rb, line 44 def run(queue) # we can abort the loop if stop? becomes true @scheduler.cron @cron do # because the sleep interval can be big, when shutdown happens # we want to be able to abort the sleep # Stud.stoppable_sleep will frequently evaluate the given block # and abort the sleep(@interval) if the return value is true inner_run(queue) end @scheduler.join end
scrape()
click to toggle source
# File lib/logstash/inputs/yasuri.rb, line 81 def scrape() page = @agent.get(@url) @tree.inject(@agent, page) end
stop()
click to toggle source
# File lib/logstash/inputs/yasuri.rb, line 57 def stop # nothing to do in this case so it is not necessary to define stop # examples of common "stop" tasks: # * close sockets (unblocking blocking reads/accepts) # * cleanup temporary files # * terminate spawned threads @scheduler.shutdown end