Class: MonitorType_Beanstalk
- Inherits:
-
MonitorType_Threshold
- Object
- MonitorType
- MonitorType_Threshold
- MonitorType_Beanstalk
- Defined in:
- lib/MonitorType/Beanstalk.rb
Overview
A Beanstalk class for checking how many msgs are in a Queue
Instance Method Summary collapse
-
#extractParams ⇒ Object
Extract parameters.
- #getValue ⇒ Object
- #setup ⇒ Object
Methods inherited from MonitorType_Threshold
Methods inherited from MonitorType
#alert, #initialize, #process, #run, #teardown
Constructor Details
This class inherits a constructor from MonitorType_Threshold
Instance Method Details
#extractParams ⇒ Object
Extract parameters
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/MonitorType/Beanstalk.rb', line 11 def extractParams() @connection_string = @params[:beanstalk] || "localhost:11300" if @params[:queue].nil? then string = "*** Beanstalk parameter missing, queue\n" string = "#{string}*** :queue => <queue name>" raise MonitorTypeParameterMissingError.new(string) end @queue = @params[:queue] @context_sentence = "Checking number of jobs in queue, #{@queue}" end |
#getValue ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/MonitorType/Beanstalk.rb', line 30 def getValue count = 0 begin tubeStats = @beanstalk.stats_tube(@queue) count = tubeStats["current-jobs-ready"] rescue Beanstalk::NotFoundError=>e end return count end |
#setup ⇒ Object
25 26 27 |
# File 'lib/MonitorType/Beanstalk.rb', line 25 def setup @beanstalk = Beanstalk::Pool.new([@connection_string]) end |