Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 26 lines (23 sloc) 638 Bytes
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/shared')
THRESHOLD = config(:threshold)
FROM = config(:from)
TO = config(:to)
SUBJECT = config(:subject)
warnings = []
`rabbitmqctl list_queues -q name messages`.split("\n").each do |line|
name, messages = line.split(/[ \t]+/)
messages = messages.to_i
if messages > THRESHOLD
warnings << "Queue '#{name}' has more than #{THRESHOLD} messages: #{messages}"
end
end
if !warnings.empty?
IO.popen("sendmail -t", "w") do |f|
f.puts "To: #{TO}"
f.puts "From: #{FROM}"
f.puts "Subject: #{SUBJECT}"
f.puts
f.puts warnings.join("\n")
end
end