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
-
#initialize(params) ⇒ MonitorType_Beanstalk
constructor
Constructor: Extract parameters.
- #process ⇒ Object
- #sanitise ⇒ Object
Methods inherited from MonitorType_Threshold
Methods inherited from MonitorType
Constructor Details
#initialize(params) ⇒ MonitorType_Beanstalk
Constructor: Extract parameters
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/MonitorType/Beanstalk.rb', line 15 def initialize( params ) super( params ) @connection_string = params[:beanstalk] || "localhost:11300" if params[:queue].nil? then puts "*** Beanstalk parameter missing, queue" puts "*** :queue => <queue name>" abort end @queue = params[:queue] self.sanitise rescue MonitorTypeExceptionHandled => e puts e. abort() end |
Instance Method Details
#process ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/MonitorType/Beanstalk.rb', line 31 def process count = 0 begin tubeStats = @beanstalk.stats_tube(@queue) count = tubeStats["current-jobs-ready"] rescue Beanstalk::NotFoundError=>e end self.check( count, "Checking number of jobs in queue, #{@queue}" ) end |
#sanitise ⇒ Object
7 8 9 |
# File 'lib/MonitorType/Beanstalk.rb', line 7 def sanitise @beanstalk = Beanstalk::Pool.new([@connection_string]) end |