Created
November 21, 2010 14:15
-
-
Save sr/708765 to your computer and use it in GitHub Desktop.
cloudkick plugin for resque
This file contains hidden or 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 | |
$:.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