riemann-tools 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +13 -0
- data/.github/workflows/codeql-analysis.yml +72 -0
- data/.rubocop.yml +32 -0
- data/CHANGELOG.md +31 -2
- data/README.markdown +8 -24
- data/Rakefile +4 -2
- data/SECURITY.md +42 -0
- data/bin/riemann-apache-status +92 -78
- data/bin/riemann-bench +54 -49
- data/bin/riemann-cloudant +44 -40
- data/bin/riemann-consul +82 -76
- data/bin/riemann-dir-files-count +53 -47
- data/bin/riemann-dir-space +53 -47
- data/bin/riemann-diskstats +78 -75
- data/bin/riemann-fd +68 -48
- data/bin/riemann-freeswitch +108 -103
- data/bin/riemann-haproxy +46 -40
- data/bin/riemann-health +4 -343
- data/bin/riemann-kvminstance +18 -13
- data/bin/riemann-memcached +35 -29
- data/bin/riemann-net +4 -104
- data/bin/riemann-nginx-status +74 -67
- data/bin/riemann-ntp +4 -33
- data/bin/riemann-portcheck +40 -31
- data/bin/riemann-proc +96 -90
- data/bin/riemann-varnish +51 -45
- data/bin/riemann-zookeeper +38 -34
- data/lib/riemann/tools/health.rb +347 -0
- data/lib/riemann/tools/net.rb +104 -0
- data/lib/riemann/tools/ntp.rb +41 -0
- data/lib/riemann/tools/version.rb +1 -1
- data/lib/riemann/tools.rb +37 -40
- data/riemann-tools.gemspec +4 -1
- data/tools/riemann-aws/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-aws/bin/riemann-aws-billing +72 -66
- data/tools/riemann-aws/bin/riemann-aws-rds-status +55 -41
- data/tools/riemann-aws/bin/riemann-aws-sqs-status +37 -31
- data/tools/riemann-aws/bin/riemann-aws-status +63 -51
- data/tools/riemann-aws/bin/riemann-elb-metrics +149 -148
- data/tools/riemann-aws/bin/riemann-s3-list +70 -65
- data/tools/riemann-aws/bin/riemann-s3-status +85 -82
- data/tools/riemann-chronos/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-chronos/bin/riemann-chronos +136 -119
- data/tools/riemann-docker/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-docker/bin/riemann-docker +163 -174
- data/tools/riemann-elasticsearch/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +155 -147
- data/tools/riemann-marathon/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-marathon/bin/riemann-marathon +138 -122
- data/tools/riemann-mesos/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-mesos/bin/riemann-mesos +125 -110
- data/tools/riemann-munin/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-munin/bin/riemann-munin +28 -22
- data/tools/riemann-rabbitmq/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +226 -222
- data/tools/riemann-riak/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-riak/bin/riemann-riak +281 -289
- data/tools/riemann-riak/riak_status/riak_status.rb +39 -39
- metadata +65 -16
@@ -1,131 +1,146 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
Process.setproctitle($PROGRAM_NAME)
|
3
5
|
|
4
6
|
require 'riemann/tools'
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
connection
|
25
|
-
response =
|
26
|
-
|
27
|
-
|
8
|
+
module Riemann
|
9
|
+
module Tools
|
10
|
+
class Mesos
|
11
|
+
include Riemann::Tools
|
12
|
+
|
13
|
+
require 'faraday'
|
14
|
+
require 'json'
|
15
|
+
require 'uri'
|
16
|
+
|
17
|
+
opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
|
18
|
+
opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
|
19
|
+
opt :path_prefix,
|
20
|
+
'Mesos path prefix for proxied installations e.g. "mesos" for target http://localhost/mesos/metrics/snapshot', default: '/'
|
21
|
+
opt :mesos_host, 'Mesos host', default: 'localhost'
|
22
|
+
opt :mesos_port, 'Mesos port', type: :int, default: 5050
|
23
|
+
|
24
|
+
# Handles HTTP connections and GET requests safely
|
25
|
+
def safe_get(uri)
|
26
|
+
# Handle connection timeouts
|
27
|
+
response = nil
|
28
|
+
begin
|
29
|
+
connection = Faraday.new(uri)
|
30
|
+
response = connection.get do |req|
|
31
|
+
req.options[:timeout] = options[:read_timeout]
|
32
|
+
req.options[:open_timeout] = options[:open_timeout]
|
33
|
+
end
|
34
|
+
rescue StandardError => e
|
35
|
+
report(
|
36
|
+
host: uri.host,
|
37
|
+
service: 'mesos health',
|
38
|
+
state: 'critical',
|
39
|
+
description: "HTTP connection error: #{e.class} - #{e.message}",
|
40
|
+
)
|
28
41
|
end
|
29
|
-
|
30
|
-
report(:host => uri.host,
|
31
|
-
:service => "mesos health",
|
32
|
-
:state => "critical",
|
33
|
-
:description => "HTTP connection error: #{e.class} - #{e.message}"
|
34
|
-
)
|
42
|
+
response
|
35
43
|
end
|
36
|
-
response
|
37
|
-
end
|
38
44
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def slaves_url
|
47
|
-
path_prefix = options[:path_prefix]
|
48
|
-
path_prefix[0] = '' if path_prefix[0]=='/'
|
49
|
-
path_prefix[path_prefix.length-1] = '' if path_prefix[path_prefix.length-1]=='/'
|
50
|
-
"http://#{options[:mesos_host]}:#{options[:mesos_port]}#{path_prefix.length>0?'/':''}#{path_prefix}/master/slaves"
|
51
|
-
end
|
45
|
+
def health_url
|
46
|
+
path_prefix = options[:path_prefix]
|
47
|
+
path_prefix[0] = '' if path_prefix[0] == '/'
|
48
|
+
path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
|
49
|
+
"http://#{options[:mesos_host]}:#{options[:mesos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/metrics/snapshot"
|
50
|
+
end
|
52
51
|
|
52
|
+
def slaves_url
|
53
|
+
path_prefix = options[:path_prefix]
|
54
|
+
path_prefix[0] = '' if path_prefix[0] == '/'
|
55
|
+
path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
|
56
|
+
"http://#{options[:mesos_host]}:#{options[:mesos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/master/slaves"
|
57
|
+
end
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
59
|
+
def tick
|
60
|
+
tick_slaves
|
61
|
+
uri = URI(health_url)
|
62
|
+
response = safe_get(uri)
|
63
|
+
|
64
|
+
return if response.nil?
|
65
|
+
|
66
|
+
if response.status != 200
|
67
|
+
report(
|
68
|
+
host: uri.host,
|
69
|
+
service: 'mesos health',
|
70
|
+
state: 'critical',
|
71
|
+
description: "HTTP connection error: #{response.status} - #{response.body}",
|
72
|
+
)
|
73
|
+
else
|
74
|
+
# Assuming that a 200 will give json
|
75
|
+
json = JSON.parse(response.body)
|
76
|
+
state = 'ok'
|
77
|
+
|
78
|
+
report(
|
79
|
+
host: uri.host,
|
80
|
+
service: 'mesos health',
|
81
|
+
state: state,
|
82
|
+
)
|
83
|
+
|
84
|
+
json.each_pair do |k, v|
|
85
|
+
report(
|
86
|
+
host: uri.host,
|
87
|
+
service: "mesos #{k}",
|
88
|
+
metric: v,
|
89
|
+
)
|
90
|
+
end
|
91
|
+
end
|
81
92
|
end
|
82
|
-
end
|
83
|
-
end
|
84
93
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
94
|
+
def tick_slaves
|
95
|
+
uri = URI(slaves_url)
|
96
|
+
response = safe_get(uri)
|
97
|
+
|
98
|
+
return if response.nil?
|
99
|
+
|
100
|
+
if response.status != 200
|
101
|
+
report(
|
102
|
+
host: uri.host,
|
103
|
+
service: 'mesos health',
|
104
|
+
state: 'critical',
|
105
|
+
description: "HTTP connection error: #{response.status} - #{response.body}",
|
106
|
+
)
|
107
|
+
else
|
108
|
+
# Assuming that a 200 will give json
|
109
|
+
json = JSON.parse(response.body)
|
110
|
+
state = 'ok'
|
111
|
+
|
112
|
+
report(
|
113
|
+
host: uri.host,
|
114
|
+
service: 'mesos health',
|
115
|
+
state: state,
|
116
|
+
)
|
117
|
+
|
118
|
+
json['slaves'].each do |slave|
|
119
|
+
next unless slave.respond_to? 'each_pair'
|
120
|
+
|
121
|
+
slave.each_pair do |k, v|
|
122
|
+
if v.respond_to? 'each_pair'
|
123
|
+
v.each_pair do |k1, v1|
|
124
|
+
next unless v1.is_a? Numeric
|
125
|
+
|
126
|
+
report(
|
127
|
+
host: slave['hostname'],
|
128
|
+
service: "mesos slave/#{k}/#{k1}",
|
129
|
+
metric: v1,
|
115
130
|
)
|
116
131
|
end
|
132
|
+
elsif v.is_a? Numeric
|
133
|
+
report(
|
134
|
+
host: slave['hostname'],
|
135
|
+
service: "mesos slave/#{k}",
|
136
|
+
metric: v,
|
137
|
+
)
|
117
138
|
end
|
118
|
-
elsif v.is_a? Numeric
|
119
|
-
report(:host => slave["hostname"],
|
120
|
-
:service => "mesos slave/#{k}",
|
121
|
-
:metric => v
|
122
|
-
)
|
123
139
|
end
|
124
140
|
end
|
125
141
|
end
|
126
142
|
end
|
127
143
|
end
|
128
|
-
end
|
144
|
+
end
|
129
145
|
end
|
130
146
|
Riemann::Tools::Mesos.run
|
131
|
-
|
@@ -1,37 +1,43 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
Process.setproctitle($PROGRAM_NAME)
|
3
5
|
|
4
6
|
# Gathers munin statistics and submits them to Riemann.
|
5
7
|
|
6
8
|
require 'riemann/tools'
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
module Riemann
|
11
|
+
module Tools
|
12
|
+
class Munin
|
13
|
+
include Riemann::Tools
|
14
|
+
require 'munin-ruby'
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
def initialize
|
17
|
+
@munin = ::Munin::Node.new
|
18
|
+
end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
def tick
|
21
|
+
services = opts[:services] || @munin.list
|
22
|
+
services.each do |service_name|
|
23
|
+
@munin.fetch(service_name).each do |service, parts|
|
24
|
+
parts.each do |part, metric|
|
25
|
+
report(
|
26
|
+
service: "#{service} #{part}",
|
27
|
+
metric: metric.to_f,
|
28
|
+
state: 'ok',
|
29
|
+
tags: ['munin'],
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
35
|
+
|
36
|
+
opt :munin_host, 'Munin hostname', default: 'localhost'
|
37
|
+
opt :munin_port, 'Munin port', default: 4949
|
38
|
+
opt :services, 'Munin services to translate (if not specified, all services are relayed)', type: :strings
|
29
39
|
end
|
30
40
|
end
|
31
|
-
|
32
|
-
opt :munin_host, "Munin hostname", :default => 'localhost'
|
33
|
-
opt :munin_port, "Munin port", :default => 4949
|
34
|
-
opt :services, "Munin services to translate (if not specified, all services are relayed)", :type => :strings
|
35
41
|
end
|
36
42
|
|
37
43
|
Riemann::Tools::Munin.run
|