Sha256: 14743b8b5e37454d0e24f0feeeac2f007e8bab252ad2b371944047557e2134cc
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
#!/usr/bin/env ruby # encoding: UTF-8 # # Check RabbitMQ Queues Synchronised # === # # DESCRIPTION: # This plugin checks that all mirrored queues which have slaves are synchronised. # # PLATFORMS: # Linux, BSD, Solaris # # DEPENDENCIES: # gem: sensu-plugin # gem: rest-client # # LICENSE: # Copyright 2017 Cyril Gaudin <cyril.gaudin@gmail.com> # # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. require 'rest_client' require 'sensu-plugins-rabbitmq' # main plugin class class CheckRabbitMQQueuesSynchronised < Sensu::Plugin::RabbitMQ::Check option :list_queues, description: 'If set, will ouput the list of all unsynchronised queues, otherwise only the count', long: '--list-queues', boolean: true, default: false def run @crits = [] queues = get_queues config queues.each do |q| next unless q.key?('slave_nodes') nb_slaves = q['slave_nodes'].count next if nb_slaves.zero? unsynchronised = nb_slaves - q['synchronised_slave_nodes'].count if unsynchronised != 0 @crits << "#{q['name']}: #{unsynchronised} unsynchronised slave(s)" end end if @crits.empty? ok elsif config[:list_queues] critical @crits.join(' - ') else critical "#{@crits.count} unsynchronised queue(s)" end rescue Errno::ECONNREFUSED => e critical e.message rescue => e unknown e.message end def get_queues(config) url_prefix = config[:ssl] ? 'https' : 'http' options = { user: config[:username], password: config[:password] } resource = RestClient::Resource.new( "#{url_prefix}://#{config[:host]}:#{config[:port]}/api/queues", options ) JSON.parse(resource.get) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-rabbitmq-3.6.0 | bin/check-rabbitmq-queues-synchronised.rb |