Skip to content

Commit

Permalink
Add check broker (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
obazoud committed Dec 23, 2018
1 parent 63169d2 commit 7a23d6c
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions bin/check-broker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#! /usr/bin/env ruby
#
# check-broker
#
# DESCRIPTION:
# This plugin checks broker properties.
#
# OUTPUT:
# plain-text
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
# gem: sensu-plugin
# gem: zookeeper
#
# USAGE:
# ./check-broker
#
# NOTES:
#
# LICENSE:
# Olivier Bazoud
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
#

require 'sensu-plugin/check/cli'
require 'json'
require 'zookeeper'

class BrokerCheck < Sensu::Plugin::Check::CLI
option :zookeeper,
description: 'ZooKeeper connect string (host:port,..)',
short: '-z ZOOKEEPER',
long: '--zookeeper ZOOKEEPER',
default: 'localhost:2181',
required: true

option :ids,
description: 'Brokers ids',
short: '-n IDS',
long: '--name IDS',
proc: proc { |a| a.split(',') },
required: true

def run
z = Zookeeper.new(config[:zookeeper])

brokers = z.get(path: '/brokers')[:data]

critical "Broker '#{brokers}' not found"

ok
rescue => e
puts "Error: #{e.backtrace}"
critical "Error: #{e}"
end
end

0 comments on commit 7a23d6c

Please sign in to comment.