riemann-mesos 0.1.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 (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +10 -0
  4. data/bin/riemann-mesos +80 -0
  5. metadata +88 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7cd206bdeee53822299ec8bb3a50c221fbed6bfc
4
+ data.tar.gz: 3164e1f5a7e155edb37c3268b809ac120f1ccaf3
5
+ SHA512:
6
+ metadata.gz: 04db09475bd3a51023443c13e18b450273300bb05c4437f297f5bdc3c85e10872304568f16d303932e0ead7f3d5826ac1413c92d52e425f681cddc26cd54dcbe
7
+ data.tar.gz: f59832a7a81c0eb41a58701f384be6f51de8b505d9d3249a005ae568b639d03590df98b47cea6844a4479addc9c99c6397ae125b1e7efcc576a4225502a09cc9
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Kyle Kingsbury
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,10 @@
1
+ # Riemann Mesos
2
+
3
+ Gathers Mesos metrics and sends them to Riemann.
4
+
5
+ # Getting started
6
+
7
+ ```
8
+ gem install riemann-mesos
9
+ riemann-mesos --help
10
+ ```
data/bin/riemann-mesos ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'riemann/tools'
4
+
5
+ class Riemann::Tools::Mesos
6
+ include Riemann::Tools
7
+
8
+ require 'faraday'
9
+ require 'json'
10
+ require 'uri'
11
+
12
+ opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
13
+ opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
14
+ opt :path_prefix, 'Mesos path prefix for proxied installations e.g. "mesos" for target http://localhost/mesos/metrics/snapshot', default: "/"
15
+ opt :mesos_host, 'Mesos host', default: "localhost"
16
+ opt :mesos_port, 'Mesos port', type: :int, default: 5050
17
+
18
+ # Handles HTTP connections and GET requests safely
19
+ def safe_get(uri)
20
+ # Handle connection timeouts
21
+ response = nil
22
+ begin
23
+ connection = Faraday.new(uri)
24
+ response = connection.get do |req|
25
+ req.options[:timeout] = options[:read_timeout]
26
+ req.options[:open_timeout] = options[:open_timeout]
27
+ end
28
+ rescue => e
29
+ report(:host => uri.host,
30
+ :service => "mesos health",
31
+ :state => "critical",
32
+ :description => "HTTP connection error: #{e.class} - #{e.message}"
33
+ )
34
+ end
35
+ response
36
+ end
37
+
38
+ def health_url
39
+ path_prefix = options[:path_prefix]
40
+ path_prefix[0] = '' if path_prefix[0]=='/'
41
+ path_prefix[path_prefix.length-1] = '' if path_prefix[path_prefix.length-1]=='/'
42
+ "http://#{options[:mesos_host]}:#{options[:mesos_port]}#{path_prefix.length>0?'/':''}#{path_prefix}/metrics/snapshot"
43
+ end
44
+
45
+ def tick
46
+ uri = URI(health_url)
47
+ response = safe_get(uri)
48
+
49
+ return if response.nil?
50
+
51
+ if response.status != 200
52
+ report(:host => uri.host,
53
+ :service => "mesos health",
54
+ :state => "critical",
55
+ :description => "HTTP connection error: #{response.status} - #{response.body}"
56
+ )
57
+ else
58
+ # Assuming that a 200 will give json
59
+ json = JSON.parse(response.body)
60
+ state = "ok"
61
+
62
+ report(:host => uri.host,
63
+ :service => "mesos health",
64
+ :state => state)
65
+
66
+ json.each_pair do |k,v|
67
+ report(:host => uri.host,
68
+ :service => "mesos #{k}",
69
+ :metric => v
70
+ )
71
+
72
+ end
73
+ end
74
+ end
75
+
76
+
77
+
78
+ end
79
+ Riemann::Tools::Mesos.run
80
+
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riemann-mesos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Giulio Eulisse
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
+ name: riemann-tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.7
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.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email: giulio.eulisse@cern.ch
57
+ executables:
58
+ - riemann-mesos
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE
63
+ - README.md
64
+ - bin/riemann-mesos
65
+ homepage: https://github.com/riemann/riemann-mesos
66
+ licenses: []
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.8.7
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project: riemann-mesos
84
+ rubygems_version: 2.4.5
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Submits mesos stats to riemann.
88
+ test_files: []