riemann-cassandra 0.1.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e60f91ac2ff3d3870b0e1588c73ad8ecf827ba5
4
+ data.tar.gz: 6841b5abf41188c92bd3b7d55941fce3ebc39064
5
+ SHA512:
6
+ metadata.gz: a80cec281558534d6a54b193ce03cef0a57f88d90ac0a434fce60ca0ffe966cd67666cbd875e0f43d37bf9e444e0a0cc35792229f347d190515b35c73f5debe4
7
+ data.tar.gz: 4d1137d256bf1f184e47aa32cd2c0f0592ed442fb82dce24520eddfa931c69434de8f028ac5c5727b8bc5ed32497b9f5f1903cfc165ecfa20ee9e4b9afff0121
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .ruby-version
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ ruby '2.2.2', :engine => 'jruby', :engine_version => '9.0.3.0'
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Deyan Dobrinov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Riemann::Cassandra
2
+ Gem for sending Cassandra metrics to Riemann. To use it you will need a JMX enabled Cassandra and JRuby.
3
+
4
+ # Metrics
5
+ * Throughput (writes|reads)
6
+ * Latency (writes|reads)
7
+ * Key cache hit rate
8
+ * Timeout exceptions (writes|reads)
9
+ * Unavailable exceptions (writes|reads)
10
+ * (TODO) Load
11
+ * (TODO) Total disk space used
12
+ * (TODO) Completed compaction tasks
13
+ * (TODO) Pending compaction tasks
14
+ * (TODO) ParNew garbage collections (count|time)
15
+ * (TODO) CMS garbage collections (count|time)
16
+ * (TODO) Exceptions
17
+ * (TODO) Pending tasks (per stage)
18
+ * (TODO) Currently blocked tasks
19
+
20
+ More:
21
+ * https://www.datadoghq.com/blog/how-to-monitor-cassandra-performance-metrics/
22
+ * https://www.datadoghq.com/blog/how-to-collect-cassandra-metrics/
23
+
24
+ ## Installation
25
+ 1. Install [JRuby](http://jruby.org/)
26
+ 2. Run `$ gem install riemann-cassandra`
27
+
28
+ ## Usage
29
+ `riemann-cassandra --host my.riemann.server --cassandra_jmx_host my.cassandra.server --cassandra_jmx_port 7199`
30
+
31
+ ## License
32
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ require 'trollop'
3
+ require 'socket'
4
+ require 'riemann/client'
5
+ require 'riemann/cassandra'
6
+
7
+ opts_parser = Trollop::Parser.new do
8
+ opt :host, "Riemann host", default: '127.0.0.1'
9
+ opt :port, "Riemann port", default: 5555
10
+ opt :event_host, "Event hostname", type: String, default: Socket.gethostname
11
+ opt :interval, "Seconds between updates", type: :int, default: 5
12
+ opt :tag, "Tag to add to events", type: String, multi: true
13
+ opt :ttl, "TTL for events", type: Integer, default: 10
14
+ opt :attribute, "Attribute to add to the event", type: String, multi: true
15
+ opt :timeout, "Timeout (in seconds) when waiting for acknowledgements", default: 30
16
+ opt :tcp, "Use TCP transport instead of UDP (improves reliability, slight overhead.", default: true
17
+
18
+ opt :cassandra_jmx_host, 'Cassandra JMX host', type: :string, default: "localhost"
19
+ opt :cassandra_jmx_port, 'Cassandra JMX port', type: :int, default: 7199
20
+ end
21
+
22
+ opts = Trollop::with_standard_exception_handling opts_parser do
23
+ opts_parser.parse ARGV
24
+ end
25
+
26
+ # Initialise Riemann client
27
+ riemann = Riemann::Client.new(host: opts[:host], port: opts[:port], timeout: opts[:timeout])
28
+
29
+ if opts[:tcp]
30
+ riemann = riemann.tcp
31
+ else
32
+ riemann = riemann.udp
33
+ end
34
+
35
+ # Initialise Cassandra JMX client
36
+ cassandra = Riemann::Cassandra::Client.new opts[:cassandra_jmx_host], opts[:cassandra_jmx_port]
37
+
38
+ loop do
39
+ begin
40
+ # Send metric events
41
+ Riemann::Cassandra::METRIC_PARAMS.each do |mp|
42
+ metric_event = {
43
+ service: "cassandra #{mp[:service]}",
44
+ host: opts[:event_host],
45
+ metric: cassandra.metric(mp[:type], mp[:scope], mp[:name], mp[:attribute]),
46
+ description: mp[:description],
47
+ time: Time.now.utc.to_i,
48
+ tags: opts[:tags],
49
+ ttl: opts[:ttl]
50
+ }
51
+
52
+ riemann << metric_event
53
+ puts metric_event
54
+ end
55
+
56
+ # Send health event
57
+ # health_event = {
58
+ # service: 'cassandra health',
59
+ # host: opts[:event_host],
60
+ # state: 'ok',
61
+ # description: 'Cassandra status connection ok',
62
+ # time: Time.now.utc.to_i,
63
+ # tags: opts[:tags],
64
+ # ttl: opts[:ttl]
65
+ # }
66
+
67
+ # riemann << health_event
68
+ # puts health_event
69
+ puts "\n"
70
+ rescue => e
71
+ $stderr.puts "#{e.class} #{e}\n#{e.backtrace.join "\n"}"
72
+ end
73
+
74
+ sleep(opts[:interval])
75
+ end
@@ -0,0 +1,8 @@
1
+ require 'riemann/cassandra/version'
2
+ require 'riemann/cassandra/client'
3
+ require 'riemann/cassandra/metric_params'
4
+
5
+ module Riemann
6
+ module Cassandra
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ require 'java'
2
+
3
+ import javax.management.ObjectName
4
+ import javax.management.remote.JMXConnectorFactory
5
+ import javax.management.remote.JMXServiceURL
6
+
7
+ module Riemann
8
+ module Cassandra
9
+ class Client
10
+ attr_reader :mbean_server_connection
11
+
12
+ def initialize(hostname, port)
13
+ @service_url = JMXServiceURL.new("service:jmx:rmi:///jndi/rmi://#{hostname}:#{port}/jmxrmi")
14
+ @mbean_server_connection = JMXConnectorFactory.connect(@service_url, nil).getMBeanServerConnection
15
+ end
16
+
17
+ def metric(type, scope, name, attribute)
18
+ jmx_path = "org.apache.cassandra.metrics:type=#{type},scope=#{scope},name=#{name}"
19
+ mbean_server_connection.get_attribute(ObjectName.new(jmx_path), attribute)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module Riemann
2
+ module Cassandra
3
+ # https://www.datadoghq.com/blog/how-to-collect-cassandra-metrics/
4
+ METRIC_PARAMS = [
5
+ { service: 'read_throughput', type: 'ClientRequest', scope: 'Read', name: 'Latency', attribute: 'OneMinuteRate', description: '' },
6
+ { service: 'write_throughput', type: 'ClientRequest', scope: 'Write', name: 'Latency', attribute: 'OneMinuteRate', description: '' },
7
+ { service: 'total_read_latency', type: 'ClientRequest', scope: 'Read', name: 'TotalLatency', attribute: 'Count', description: '' },
8
+ { service: 'total_write_latency', type: 'ClientRequest', scope: 'Write', name: 'TotalLatency', attribute: 'Count', description: '' },
9
+ { service: 'read_latency', type: 'ClientRequest', scope: 'Read', name: 'Latency', attribute: 'Count', description: '' },
10
+ { service: 'write_latency', type: 'ClientRequest', scope: 'Write', name: 'Latency', attribute: 'Count', description: '' },
11
+ { service: 'key_cache_hits', type: 'Cache', scope: 'KeyCache', name: 'Hits', attribute: 'Count', description: '' },
12
+ { service: 'key_cache_requests', type: 'Cache', scope: 'KeyCache', name: 'Requests', attribute: 'Count', description: '' },
13
+ { service: 'read_timeout_exceptions', type: 'ClientRequest', scope: 'Read', name: 'Timeouts', attribute: 'Count', description: '' },
14
+ { service: 'write_timeout_exceptions', type: 'ClientRequest', scope: 'Write', name: 'Timeouts', attribute: 'Count', description: '' },
15
+ { service: 'read_unavailable_exceptions', type: 'ClientRequest', scope: 'Read', name: 'Unavailables', attribute: 'Count', description: '' },
16
+ { service: 'write_unavailable_exceptions', type: 'ClientRequest', scope: 'Write', name: 'Unavailables', attribute: 'Count', description: '' }
17
+ ]
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Riemann
2
+ module Cassandra
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'riemann/cassandra/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "riemann-cassandra"
8
+ spec.version = Riemann::Cassandra::VERSION
9
+ spec.authors = ["Deyan Dobrinov"]
10
+ spec.email = ["deyan.dobrinov@gmail.com"]
11
+
12
+ spec.summary = %q{Gem for sending Cassandra metrics to Riemann.}
13
+ spec.description = %q{Gem for sending Cassandra metrics to Riemann.}
14
+ spec.homepage = "https://github.com/dobrinov/riemann-cassandra"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ spec.executables = ["riemann-cassandra"]
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+
25
+ spec.required_ruby_version = '>= 2.2.2'
26
+ spec.platform = 'java'
27
+
28
+ spec.add_runtime_dependency 'riemann-client', '~> 0.2.6'
29
+ spec.add_runtime_dependency 'trollop', '~> 2.1.2'
30
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riemann-cassandra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: java
6
+ authors:
7
+ - Deyan Dobrinov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.10'
19
+ name: bundler
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '10.0'
33
+ name: rake
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.2.6
47
+ name: riemann-client
48
+ prerelease: false
49
+ type: :runtime
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.6
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 2.1.2
61
+ name: trollop
62
+ prerelease: false
63
+ type: :runtime
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.1.2
69
+ description: Gem for sending Cassandra metrics to Riemann.
70
+ email:
71
+ - deyan.dobrinov@gmail.com
72
+ executables:
73
+ - riemann-cassandra
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/riemann-cassandra
84
+ - lib/riemann/cassandra.rb
85
+ - lib/riemann/cassandra/client.rb
86
+ - lib/riemann/cassandra/metric_params.rb
87
+ - lib/riemann/cassandra/version.rb
88
+ - riemann-cassandra.gemspec
89
+ homepage: https://github.com/dobrinov/riemann-cassandra
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 2.2.2
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.8
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Gem for sending Cassandra metrics to Riemann.
113
+ test_files: []