riemann-chronos 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +10 -0
- data/bin/riemann-chronos +143 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 33720244c72bb43b8e7c9d38fd6f5459a48af3f1
|
4
|
+
data.tar.gz: f7757697d8245ce32b8915ca47a25d62076958a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 31fc2dd7300bd3687aba6d9745cee9b2c8ffcea4b5258b0345031b8edddeda3197487d6b574e6ed628edcab78261e06be16d132108ce23fc2ab5e9b957ae6093
|
7
|
+
data.tar.gz: 660353a9cc45fac972688fe436f331f9b5e7e270c2c2273527aae24be8c803c5d9b42bb5e636caaa1c87a9cf0461b3a01ec1184f687ffbe0615fe4d390c0210e
|
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
data/bin/riemann-chronos
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
class Riemann::Tools::Chronos
|
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, 'Chronos path prefix for proxied installations e.g. "chronos" for target http://localhost/chronos/metrics', default: "/"
|
15
|
+
opt :chronos_host, 'Chronos host', default: "localhost"
|
16
|
+
opt :chronos_port, 'Chronos port', type: :int, default: 4400
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
options[:interval] = 60
|
20
|
+
options[:ttl] = 120
|
21
|
+
end
|
22
|
+
|
23
|
+
# Handles HTTP connections and GET requests safely
|
24
|
+
def safe_get(uri)
|
25
|
+
# Handle connection timeouts
|
26
|
+
response = nil
|
27
|
+
begin
|
28
|
+
connection = Faraday.new(uri)
|
29
|
+
response = connection.get do |req|
|
30
|
+
req.options[:timeout] = options[:read_timeout]
|
31
|
+
req.options[:open_timeout] = options[:open_timeout]
|
32
|
+
end
|
33
|
+
rescue => e
|
34
|
+
report(:host => uri.host,
|
35
|
+
:service => "chronos health",
|
36
|
+
:state => "critical",
|
37
|
+
:description => "HTTP connection error: #{e.class} - #{e.message}"
|
38
|
+
)
|
39
|
+
end
|
40
|
+
response
|
41
|
+
end
|
42
|
+
|
43
|
+
def health_url
|
44
|
+
path_prefix = options[:path_prefix]
|
45
|
+
path_prefix[0] = '' if path_prefix[0]=='/'
|
46
|
+
path_prefix[path_prefix.length-1] = '' if path_prefix[path_prefix.length-1]=='/'
|
47
|
+
"http://#{options[:chronos_host]}:#{options[:chronos_port]}#{path_prefix.length>0?'/':''}#{path_prefix}/metrics"
|
48
|
+
end
|
49
|
+
|
50
|
+
def jobs_url
|
51
|
+
path_prefix = options[:path_prefix]
|
52
|
+
path_prefix[0] = '' if path_prefix[0]=='/'
|
53
|
+
path_prefix[path_prefix.length-1] = '' if path_prefix[path_prefix.length-1]=='/'
|
54
|
+
"http://#{options[:chronos_host]}:#{options[:chronos_port]}#{path_prefix.length>0?'/':''}#{path_prefix}/scheduler/jobs"
|
55
|
+
end
|
56
|
+
|
57
|
+
def tick
|
58
|
+
tick_health
|
59
|
+
tick_jobs
|
60
|
+
end
|
61
|
+
|
62
|
+
def tick_health
|
63
|
+
uri = URI(health_url)
|
64
|
+
response = safe_get(uri)
|
65
|
+
|
66
|
+
return if response.nil?
|
67
|
+
|
68
|
+
if response.status != 200
|
69
|
+
report(:host => uri.host,
|
70
|
+
:service => "chronos health",
|
71
|
+
:state => "critical",
|
72
|
+
:description => "HTTP connection error: #{response.status} - #{response.body}"
|
73
|
+
)
|
74
|
+
else
|
75
|
+
# Assuming that a 200 will give json
|
76
|
+
json = JSON.parse(response.body)
|
77
|
+
|
78
|
+
report(:host => uri.host,
|
79
|
+
:service => "chronos health",
|
80
|
+
:state => "ok")
|
81
|
+
|
82
|
+
json.each_pair do |t, d|
|
83
|
+
if d.respond_to? :each_pair
|
84
|
+
d.each_pair do |service, counters|
|
85
|
+
report(:host => uri.host,
|
86
|
+
:service => "chronos_metric #{t} #{service}",
|
87
|
+
:metric => 1,
|
88
|
+
:tags => ["metric_name"],
|
89
|
+
:ttl => 600
|
90
|
+
)
|
91
|
+
if counters.respond_to? :each_pair
|
92
|
+
counters.each_pair do |k, v|
|
93
|
+
if v.is_a? Numeric
|
94
|
+
report(:host => uri.host,
|
95
|
+
:service => "chronos #{service} #{k}",
|
96
|
+
:metric => v,
|
97
|
+
:tags => ["metric", "#{t}"],
|
98
|
+
:ttl => 600
|
99
|
+
)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def tick_jobs
|
110
|
+
uri = URI(jobs_url)
|
111
|
+
response = safe_get(uri)
|
112
|
+
|
113
|
+
return if response.nil?
|
114
|
+
|
115
|
+
if response.status != 200
|
116
|
+
report(:host => uri.host,
|
117
|
+
:service => "chronos health",
|
118
|
+
:state => "critical",
|
119
|
+
:description => "HTTP connection error: #{response.status} - #{response.body}"
|
120
|
+
)
|
121
|
+
else
|
122
|
+
# Assuming that a 200 will give json
|
123
|
+
json = JSON.parse(response.body)
|
124
|
+
|
125
|
+
report(:host => uri.host,
|
126
|
+
:service => "chronos health",
|
127
|
+
:state => "ok")
|
128
|
+
|
129
|
+
json.each do |job|
|
130
|
+
job.each_pair do |k, v|
|
131
|
+
if v.is_a? Numeric
|
132
|
+
report(:host => uri.host,
|
133
|
+
:service => "chronos job #{job["name"]} #{k}",
|
134
|
+
:metric => v,
|
135
|
+
:ttl => 120
|
136
|
+
)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
Riemann::Tools::Chronos.run
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riemann-chronos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Ericson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-15 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.8
|
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.8
|
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: peter.ericson@cba.com.au
|
57
|
+
executables:
|
58
|
+
- riemann-chronos
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- LICENSE
|
63
|
+
- README.md
|
64
|
+
- bin/riemann-chronos
|
65
|
+
homepage: https://github.com/riemann/riemann-tools
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.8.7
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project: riemann-chronos
|
85
|
+
rubygems_version: 2.4.5
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Submits Chronos stats to riemann.
|
89
|
+
test_files: []
|