riemann-storm 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/riemann-storm +69 -0
  3. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b7033c4877ca20bb8043017c1d1b2c5579956ac4
4
+ data.tar.gz: 1c23ec96d9cef0a9deb4e19b1b815163aabb4856
5
+ SHA512:
6
+ metadata.gz: 5ea995d0e69ad61210d56dcda38528224f70cf2486a0207ace41fc47a32aef57d457b9632b3574cb269d5b27cc082b32e12af76f63b8b30fa95e00020c2c9ccd
7
+ data.tar.gz: 2712018636468e4c0f2fbf799a2b83ec30555f948d55b8c5a9095a6d9a2363757cd3548de87a791ada4d73b48e4f19b97ded3811b3224b98ab74e8ae5a08d437
data/bin/riemann-storm ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'riemann/tools'
4
+ require 'net/http'
5
+ require 'json'
6
+
7
+ def get_json(url)
8
+ response = Net::HTTP.get(URI(url))
9
+ return JSON.parse(response)
10
+ end
11
+
12
+ class Riemann::Tools::Storm
13
+ include Riemann::Tools
14
+
15
+ CLUSTER_KEYS = ['slotsFree', 'topologies', 'supervisors', 'tasksTotal', 'slotsUsed', 'slotsTotal', 'executorsTotal']
16
+ TOPOLOGY_KEYS = ['assignedTotalMem', 'assignedCpu', 'workersTotal', 'executorsTotal', 'tasksTotal', 'uptimeSeconds']
17
+
18
+ opt :storm_ui, "Storm UI base URL", :default => 'http://localhost:8080'
19
+
20
+ def tick
21
+ begin
22
+ storm_host = URI(opts[:storm_ui]).host
23
+ summary = storm_api '/api/v1/cluster/summary'
24
+ CLUSTER_KEYS.each do |key|
25
+ if summary.key?(key)
26
+ state = 'ok'
27
+ state = 'warning' if key == 'slotsUsed' && (summary[key].to_f / summary['slotsUsed'].to_f >= 0.9)
28
+ report({
29
+ :service => "storm #{key}",
30
+ :metric => summary[key],
31
+ :state => state,
32
+ :host => storm_host
33
+ })
34
+ end
35
+ end
36
+
37
+ topologies = storm_api '/api/v1/topology/summary'
38
+ topologies['topologies'].each do |topology|
39
+ svc = "storm-topology #{topology['name']}"
40
+ if topology['status'] == 'ACTIVE'
41
+ state = 'ok'
42
+ elsif topology['status'] == 'KILLED'
43
+ state = 'critical'
44
+ else
45
+ state = 'warning'
46
+ end
47
+ report({
48
+ :service => "#{svc} status",
49
+ :state => state,
50
+ :host => storm_host
51
+ })
52
+
53
+ TOPOLOGY_KEYS.each do |key|
54
+ report({
55
+ :service => "#{svc} #{key}",
56
+ :metric => topology[key],
57
+ :host => storm_host
58
+ })
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def storm_api(path)
65
+ return get_json("#{opts[:storm_ui]}#{path}")
66
+ end
67
+ end
68
+
69
+ Riemann::Tools::Storm.run
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riemann-storm
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Bobrov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: riemann-tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.11
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.11
27
+ description:
28
+ email: bobrov@mlworks.com
29
+ executables:
30
+ - riemann-storm
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/riemann-storm
35
+ homepage: https://github.com/ML-Works/riemann-storm
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.6.8
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: A tool reporting Storm metrics to Riemann
59
+ test_files: []