-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresque_queues.rb
More file actions
executable file
·36 lines (28 loc) · 1.13 KB
/
resque_queues.rb
File metadata and controls
executable file
·36 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby
# -*- mode: ruby -*-
#%# family=auto contrib
#%# capabilities=autoconf
require 'resque'
require 'optparse'
require 'socket'
require 'statsd'
@options = {:server => 'statsd', :port => 2033, :prefix => 'statsd.prefix'}
OptionParser.new do |opts|
opts.banner = 'Usage: resque_queues.rb [options]'
opts.on('-r', '--redis RESQUE_SERVER:PORT:DB', 'Redis server and port database for resque') { |v| @options[:redis_server] = v }
opts.on('-s', '--server SENDCHANNEL_HOST', 'Statsd host') { |v| @options[:server] = v }
opts.on('-p', '--port SENDCHANNEL_PORT', 'Statsd port') { |v| @options[:port] = v }
opts.on('-e', '--prefix PREFIX', 'Statsd Prefix') { |v| @options[:prefix] = v }
end.parse!
Resque.redis = @options[:redis_server]
queues = Resque.queues
if queues.nil? || queues.empty?
puts "no: no resque info found"
exit(1)
end
stats = Resque.info
$statsd = Statsd.new @options[:server], @options[:port]
Resque.queues.each do |q|
$statsd.gauge("#{@options[:prefix]}.resque_queue_size.#{q}", Resque.size(q))
end
$statsd.gauge("#{@options[:prefix]}.resque_scheduled_jobs.size", Resque.redis.hlen(:schedules))