Class: LogStash::Inputs::Mongoprofile
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Mongoprofile
- Defined in:
- lib/logstash/inputs/mongoprofile.rb
Overview
Generate a repeating message.
This plugin is intented only as an example.
Instance Method Summary collapse
- #register ⇒ Object
-
#run(queue) ⇒ Object
def register.
-
#stop ⇒ Object
def run.
Instance Method Details
#register ⇒ Object
26 27 28 29 |
# File 'lib/logstash/inputs/mongoprofile.rb', line 26 def register @host = Socket.gethostname @controller = Controller.new(@host, @url, 'system.profile', 1000, @path, @client_host, @logger, @generate_id) end |
#run(queue) ⇒ Object
def register
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/logstash/inputs/mongoprofile.rb', line 33 def run(queue) # we can abort the loop if stop? becomes true while !stop? begin @controller.get_next_events.each do |event| @logger.debug("Send event #{event}") decorate(event) queue << event end # 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 Stud.stoppable_sleep(@interval) {stop?} rescue => e @logger.warn('MongoProfile input threw an exception, restarting', :exception => e) @logger.warn(e.backtrace.inspect) end end # loop end |
#stop ⇒ Object
def run
59 60 61 62 63 64 65 |
# File 'lib/logstash/inputs/mongoprofile.rb', line 59 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 end |