Class: MonitorTypeBeanstalk
- Inherits:
-
MonitorTypeThreshold
- Object
- MonitorType
- MonitorTypeThreshold
- MonitorTypeBeanstalk
- Defined in:
- lib/monitor_type/beanstalk.rb
Overview
A Beanstalk class for checking how many msgs are in a Queue
Instance Method Summary collapse
- #derived_value ⇒ Object
-
#extract_params ⇒ Object
Extract parameters.
- #setup ⇒ Object
Methods inherited from MonitorTypeThreshold
Methods inherited from MonitorType
#alert, #initialize, #process, #run, #teardown
Constructor Details
This class inherits a constructor from MonitorTypeThreshold
Instance Method Details
#derived_value ⇒ Object
26 27 28 29 30 31 |
# File 'lib/monitor_type/beanstalk.rb', line 26 def derived_value tube_stats = @beanstalk.stats_tube(@queue) tube_stats['current-jobs-ready'] rescue Beanstalk::NotFoundError 0 end |
#extract_params ⇒ Object
Extract parameters
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/monitor_type/beanstalk.rb', line 9 def extract_params @connection_string = @params[:beanstalk] || 'localhost:11300' if @params[:queue].nil? string = "*** Beanstalk parameter missing, queue\n" \ '*** :queue => <queue name>' fail MonitorTypeParameterMissingError, string end @queue = @params[:queue] @context_sentence = "Checking number of jobs in queue, #{@queue}" end |
#setup ⇒ Object
22 23 24 |
# File 'lib/monitor_type/beanstalk.rb', line 22 def setup @beanstalk = Beanstalk::Pool.new([@connection_string]) end |