Last active
August 29, 2015 14:09
-
-
Save phumpal/a82a2c7ac9fb1c752224 to your computer and use it in GitHub Desktop.
Checks the specified resque queue size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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