Skip to content

Instantly share code, notes, and snippets.

@sr
Created November 21, 2010 14:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sr/708765 to your computer and use it in GitHub Desktop.
Save sr/708765 to your computer and use it in GitHub Desktop.
cloudkick plugin for resque
#!/usr/bin/env ruby
$:.unshift "lib"
require "init"
workers = Resque.workers
total = workers.size.to_f
idling = workers.select { |w| w.idle? }.size
working = Resque.working.reject { |w| w.idle? }.size.to_f
busyness = (working / total) * 100
info = Resque.info
failed = info[:failed]
processed = info[:processed]
queues = info[:queues]
if busyness == 100
puts "status err out of workers"
elsif busyness >= 60
puts "status err backed up #{idling} free workers"
elsif busyness >= 40
puts "status warn #{idling} free workers"
else
puts "status ok #{idling} free workers"
end
puts "metric working int #{working}"
puts "metric idling int #{idling}"
puts "metric proccessed int #{processed}"
puts "metric failed int #{failed}"
puts "metric queues int #{queues}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment