diff --git a/Gemfile b/Gemfile index 2a43310..501d201 100644 --- a/Gemfile +++ b/Gemfile @@ -3,4 +3,5 @@ source 'https://rubygems.org' gem 'zookeeper' gem 'zk' gem 'json' -gem 'trollop' \ No newline at end of file +gem 'trollop' +gem 'simple-graphite' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..4213416 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,22 @@ +GEM + remote: https://rubygems.org/ + specs: + json (2.0.3) + simple-graphite (2.1.0) + trollop (2.1.2) + zk (1.9.6) + zookeeper (~> 1.4.0) + zookeeper (1.4.11) + +PLATFORMS + ruby + +DEPENDENCIES + json + simple-graphite + trollop + zk + zookeeper + +BUNDLED WITH + 1.13.6 diff --git a/README.md b/README.md index b30f2a0..43a811c 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,21 @@ How it works Usage ----- -1. Set the script to be executable +1. Install dependencies (requires ruby and bundler) +```sh +bundle install ``` -chmod +x kafka_status.rb + +2. Set the script to be executable + +``` +chmod +x cli.rb ``` -2. Place the script somewhere like `/usr/local/bin/kafka_status` +3. Place the script somewhere like `/usr/local/bin/kafka_status` -3. Run the script, e.g. +4. Run the script, e.g. ``` bburton@lookout-kafka-bburton-2:~$ /usr/local/bin/kafka_status diff --git a/cli.rb b/cli.rb index a0c57e3..008f0fe 100755 --- a/cli.rb +++ b/cli.rb @@ -5,7 +5,7 @@ require 'rubygems' require 'trollop' -require 'lib/status' +require_relative 'lib/status' SUB_COMMANDS = %w(status consumer_lag) global_opts = Trollop::options do @@ -27,7 +27,7 @@ opt :verbose, "Verbose output?", :required => false end else - Trollop::die "Use status or consumer_lag" + Trollop::die "kafka-status: Use status or consumer_lag" end diff --git a/lib/consumer.rb b/lib/consumer.rb index e0bdcf8..a90d57d 100644 --- a/lib/consumer.rb +++ b/lib/consumer.rb @@ -1,6 +1,6 @@ # # consumer.rb -require 'lib/zookeeper' +require_relative 'zookeeper' require 'simple-graphite' def underscore(metric) @@ -128,5 +128,5 @@ def consumer_lag() consumer_group_data.each do | topic_name, topic_data | partition_consumer_data(consumer_group_name, topic_name, topic_data) end - end -end \ No newline at end of file + end +end diff --git a/lib/status.rb b/lib/status.rb index e604c1b..d1ce7ca 100644 --- a/lib/status.rb +++ b/lib/status.rb @@ -1,8 +1,8 @@ # status.rb -require 'lib/zookeeper' -require 'lib/broker' -require 'lib/consumer' +require_relative './zookeeper' +require_relative './broker' +require_relative './consumer' def kafka_status() @@ -37,4 +37,4 @@ def kafka_status() end end end -end \ No newline at end of file +end