riemann-tools 1.0.0 → 1.1.0

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