Skip to content

Instantly share code, notes, and snippets.

@viniciusdaniel
Created May 4, 2012 23:11
Show Gist options
  • Save viniciusdaniel/2598272 to your computer and use it in GitHub Desktop.
Save viniciusdaniel/2598272 to your computer and use it in GitHub Desktop.
munin plugin for show active resque workers
#!/usr/bin/env ruby
# Description: Show number of workers active by queue based on "https://gist.github.com/1334470"
# Source: https://gist.github.com/2598272
#
require 'rubygems'
require 'resque'
HOST = ENV['host'] ? ENV['host'] : '127.0.0.1'
PORT = ENV['port'] ? ENV['port'] : '6379'
Resque.redis = "#{HOST}:#{PORT}"
queues = {}
Resque.queues.each do |queue|
queues[queue] = 0
end
if ARGV.any? && ARGV[0] == 'config'
puts 'graph_title Workers by Queues'
puts 'graph_vlabel Workers'
puts 'graph_category resque'
queues.keys.each do |queue|
puts "#{queue}_workers.label #{queue}"
end
exit 0
end
Resque.working.map{ |w| w.to_s.split(':').last }.each do |q|
queues[q] += 1
end
queues.each_pair{ |queue, workers|
puts "#{queue}_workers.value #{workers}"
}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment