Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Checks the specified resque queue size
#!/usr/bin/env ruby
#
# Check the size of a resque queue
# ===
#
# Copyright 2014 Patrick Humpal <patrick@netvilla.net>
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-plugin/check/cli'
require 'socket'
require 'resque'
require 'resque/failure/redis'
class ResqueQueueSize < Sensu::Plugin::Check::CLI
option :host,
:short => "-h HOST",
:long => "--host HOST",
:description => "Redis host to connect to",
:required => true
option :port,
:short => "-P PORT",
:long => "--port PORT",
:description => "Redis port to connect to",
:default => "6379"
option :queue,
:description => "Resque queue",
:short => "-q QUEUE",
:long => "--queue QUEUE",
:default => "resque"
option :warn,
:description => 'Warn if COUNT or more',
:short => '-w COUNT',
:long => '--warn COUNT',
:default => 250
option :crit,
:description => 'Critical if COUNT or more',
:short => '-c COUNT',
:long => '--critical COUNT',
:default => 500
def run
redis = Redis.new(:host => config[:hostname], :port => config[:port])
Resque.redis = redis
sz = Resque.size("#{config[:queue]}")
output "Queue size is #{sz}"
critical if sz >= config[:crit]
warning if sz >= config[:warn]
ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.