riemann-tools 0.2.14 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +5 -5
  2. data/.docker/Dockerfile +7 -0
  3. data/.docker/publish.sh +35 -0
  4. data/.github/dependabot.yml +11 -0
  5. data/.github/workflows/ci.yml +42 -0
  6. data/.github/workflows/codeql-analysis.yml +72 -0
  7. data/.gitignore +6 -0
  8. data/.rspec +2 -0
  9. data/.rubocop.yml +32 -0
  10. data/.travis.yml +31 -0
  11. data/CHANGELOG.md +430 -0
  12. data/Gemfile +6 -0
  13. data/ISSUE_TEMPLATE.md +15 -0
  14. data/README.markdown +13 -16
  15. data/Rakefile +23 -0
  16. data/SECURITY.md +42 -0
  17. data/bin/riemann-apache-status +92 -77
  18. data/bin/riemann-bench +54 -48
  19. data/bin/riemann-cloudant +44 -39
  20. data/bin/riemann-consul +82 -75
  21. data/bin/riemann-dir-files-count +53 -46
  22. data/bin/riemann-dir-space +53 -46
  23. data/bin/riemann-diskstats +78 -74
  24. data/bin/riemann-fd +68 -47
  25. data/bin/riemann-freeswitch +108 -102
  26. data/bin/riemann-haproxy +46 -39
  27. data/bin/riemann-health +4 -335
  28. data/bin/riemann-kvminstance +18 -12
  29. data/bin/riemann-memcached +35 -28
  30. data/bin/riemann-net +4 -103
  31. data/bin/riemann-nginx-status +74 -66
  32. data/bin/riemann-ntp +4 -32
  33. data/bin/riemann-portcheck +40 -30
  34. data/bin/riemann-proc +96 -89
  35. data/bin/riemann-varnish +51 -44
  36. data/bin/riemann-zookeeper +38 -33
  37. data/lib/riemann/tools/health.rb +347 -0
  38. data/lib/riemann/tools/net.rb +104 -0
  39. data/lib/riemann/tools/ntp.rb +41 -0
  40. data/lib/riemann/tools/utils.rb +17 -0
  41. data/lib/riemann/tools/version.rb +7 -0
  42. data/lib/riemann/tools.rb +38 -31
  43. data/riemann-tools.gemspec +42 -0
  44. data/tools/riemann-aws/LICENSE +21 -0
  45. data/tools/riemann-aws/README.md +54 -0
  46. data/tools/riemann-aws/Rakefile +37 -0
  47. data/tools/riemann-aws/bin/riemann-aws-billing +93 -0
  48. data/tools/riemann-aws/bin/riemann-aws-rds-status +68 -0
  49. data/tools/riemann-aws/bin/riemann-aws-sqs-status +50 -0
  50. data/tools/riemann-aws/bin/riemann-aws-status +83 -0
  51. data/tools/riemann-aws/bin/riemann-elb-metrics +168 -0
  52. data/tools/riemann-aws/bin/riemann-s3-list +87 -0
  53. data/tools/riemann-aws/bin/riemann-s3-status +102 -0
  54. data/tools/riemann-chronos/LICENSE +21 -0
  55. data/tools/riemann-chronos/README.md +10 -0
  56. data/tools/riemann-chronos/Rakefile +37 -0
  57. data/tools/riemann-chronos/bin/riemann-chronos +161 -0
  58. data/tools/riemann-docker/LICENSE +21 -0
  59. data/tools/riemann-docker/README.md +10 -0
  60. data/tools/riemann-docker/Rakefile +36 -0
  61. data/tools/riemann-docker/bin/riemann-docker +206 -0
  62. data/tools/riemann-elasticsearch/LICENSE +21 -0
  63. data/tools/riemann-elasticsearch/README.md +10 -0
  64. data/tools/riemann-elasticsearch/Rakefile +37 -0
  65. data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +174 -0
  66. data/tools/riemann-marathon/LICENSE +21 -0
  67. data/tools/riemann-marathon/README.md +10 -0
  68. data/tools/riemann-marathon/Rakefile +37 -0
  69. data/tools/riemann-marathon/bin/riemann-marathon +163 -0
  70. data/tools/riemann-mesos/LICENSE +21 -0
  71. data/tools/riemann-mesos/README.md +10 -0
  72. data/tools/riemann-mesos/Rakefile +37 -0
  73. data/tools/riemann-mesos/bin/riemann-mesos +146 -0
  74. data/tools/riemann-munin/LICENSE +21 -0
  75. data/tools/riemann-munin/README.md +10 -0
  76. data/tools/riemann-munin/Rakefile +36 -0
  77. data/tools/riemann-munin/bin/riemann-munin +43 -0
  78. data/tools/riemann-rabbitmq/LICENSE +21 -0
  79. data/tools/riemann-rabbitmq/README.md +10 -0
  80. data/tools/riemann-rabbitmq/Rakefile +37 -0
  81. data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +273 -0
  82. data/tools/riemann-riak/LICENSE +21 -0
  83. data/tools/riemann-riak/README.md +10 -0
  84. data/tools/riemann-riak/Rakefile +36 -0
  85. data/tools/riemann-riak/bin/riemann-riak +323 -0
  86. data/tools/riemann-riak/bin/riemann-riak-keys +13 -0
  87. data/tools/riemann-riak/bin/riemann-riak-ring +9 -0
  88. data/tools/riemann-riak/riak_status/key_count.erl +13 -0
  89. data/tools/riemann-riak/riak_status/riak_status.rb +152 -0
  90. data/tools/riemann-riak/riak_status/ringready.erl +9 -0
  91. metadata +186 -37
data/bin/riemann-proc CHANGED
@@ -1,107 +1,114 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ Process.setproctitle($PROGRAM_NAME)
2
5
 
3
6
  # Reports running process count to riemann.
4
7
 
5
- require File.expand_path('../../lib/riemann/tools', __FILE__)
8
+ require File.expand_path('../lib/riemann/tools', __dir__)
6
9
 
7
- class Riemann::Tools::Proc
8
- include Riemann::Tools
10
+ module Riemann
11
+ module Tools
12
+ class Proc
13
+ include Riemann::Tools
9
14
 
10
- opt :proc_regex, "regular expression that matches the process to be monitored", type: :string, :default => ".*"
11
- opt :proc_min_critical, "running process count minimum", :default => 0
12
- opt :proc_max_critical, "running process count maximum", :default => 65536
15
+ opt :proc_regex, 'regular expression that matches the process to be monitored', type: :string, default: '.*'
16
+ opt :proc_min_critical, 'running process count minimum', default: 0
17
+ opt :proc_max_critical, 'running process count maximum', default: 65_536
13
18
 
14
- def initialize
15
- @limits = { :critical => { :min => opts[:proc_min_critical], :max => opts[:proc_max_critical] } }
19
+ def initialize
20
+ @limits = { critical: { min: opts[:proc_min_critical], max: opts[:proc_max_critical] } }
16
21
 
17
- abort "FATAL: specify a process regular expression, see --help for usage" unless opts[:proc_regex]
22
+ abort 'FATAL: specify a process regular expression, see --help for usage' unless opts[:proc_regex]
18
23
 
19
- ostype = `uname -s`.chomp.downcase
20
- puts "WARNING: OS '#{ostype}' not explicitly supported. Falling back to Linux" unless ostype == "linux"
21
- @check = method :linux_proc
22
- end
24
+ ostype = `uname -s`.chomp.downcase
25
+ puts "WARNING: OS '#{ostype}' not explicitly supported. Falling back to Linux" unless ostype == 'linux'
26
+ @check = method :linux_proc
27
+ end
23
28
 
24
- def alert(service, state, metric, description)
25
- report(
26
- :service => service.to_s,
27
- :state => state.to_s,
28
- :metric => metric.to_f,
29
- :description => description
30
- )
31
- end
29
+ def alert(service, state, metric, description)
30
+ report(
31
+ service: service.to_s,
32
+ state: state.to_s,
33
+ metric: metric.to_f,
34
+ description: description,
35
+ )
36
+ end
32
37
 
33
- def linux_proc
34
- process = opts[:proc_regex]
35
- found = `ps axo pid=,rss=,vsize=,state=,cputime=,lstart=,command= | grep '#{process}' | grep -v grep | grep -v riemann-proc`
36
- running = found.count("\n")
37
- if running > @limits[:critical][:max] or running < @limits[:critical][:min]
38
- alert "proc count/#{process}", :critical, running, "process #{process} is running #{running} instances.\n"
39
- else
40
- alert "proc count/#{process}", :ok, running, "process #{process} is running #{running} instances.\n"
41
- end
42
- # Iterate on all the lines and create an entry for the following metrics:
43
- #
44
- # process/<pid>-<start-time>/rss
45
- # process/<pid>-<start-time>/vsize
46
- # process/<pid>-<start-time>/running
47
- # process/<pid>-<start-time>/cputime
48
- #
49
- # description should contain the command itself.
50
- # value should be either process RSS, VSIZE, or 1 if running
51
- # state is always unknown for the moment
52
- #
53
- ps_regex = /([0-9]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+([A-Z])[ ]+([0-9:.]+)[ ]+[A-Za-z]{3}[ ]+([A-Za-z]{3}[ ]{1,2}[0-9]+ [0-9:]+ [0-9]+)[ ]+(.*)/
54
- found.each_line do |line|
55
- m = ps_regex.match(line)
56
- if not m.nil?
57
- pid, rss, vsize, state, cputime, start, command = m.captures
58
- start_s = DateTime.parse(start, "Mmm DD HH:MM:ss YYYY").to_time.to_i
59
- cputime_s = DateTime.parse(cputime, "%H:%M:%S")
60
- cputime_seconds = (cputime_s.hour * 3600) + (cputime_s.minute * 60) + cputime_s.second
61
- running = 0
62
- case state[0]
63
- when "R"
64
- state_s = "ok"
65
- running = 1
66
- when "S"
67
- state_s = "ok"
68
- when "I"
69
- state_s = "warning"
70
- when "T", "U", "Z"
71
- state_s = "critical"
38
+ def linux_proc
39
+ process = opts[:proc_regex]
40
+ found = `ps axo pid=,rss=,vsize=,state=,cputime=,lstart=,command= | grep '#{process}' | grep -v grep | grep -v riemann-proc`
41
+ running = found.count("\n")
42
+ if (running > @limits[:critical][:max]) || (running < @limits[:critical][:min])
43
+ alert "proc count/#{process}", :critical, running, "process #{process} is running #{running} instances.\n"
72
44
  else
73
- state_s = "unknown"
45
+ alert "proc count/#{process}", :ok, running, "process #{process} is running #{running} instances.\n"
46
+ end
47
+ # Iterate on all the lines and create an entry for the following metrics:
48
+ #
49
+ # process/<pid>-<start-time>/rss
50
+ # process/<pid>-<start-time>/vsize
51
+ # process/<pid>-<start-time>/running
52
+ # process/<pid>-<start-time>/cputime
53
+ #
54
+ # description should contain the command itself.
55
+ # value should be either process RSS, VSIZE, or 1 if running
56
+ # state is always unknown for the moment
57
+ #
58
+ ps_regex = /([0-9]+) +([0-9]+) +([0-9]+) +([A-Z]) +([0-9:.]+) +[A-Za-z]{3} +([A-Za-z]{3} {1,2}[0-9]+ [0-9:]+ [0-9]+) +(.*)/
59
+ found.each_line do |line|
60
+ m = ps_regex.match(line)
61
+ next if m.nil?
62
+
63
+ pid, rss, vsize, state, cputime, start, command = m.captures
64
+ start_s = DateTime.parse(start, 'Mmm DD HH:MM:ss YYYY').to_time.to_i
65
+ cputime_s = DateTime.parse(cputime, '%H:%M:%S')
66
+ cputime_seconds = (cputime_s.hour * 3600) + (cputime_s.minute * 60) + cputime_s.second
67
+ running = 0
68
+ case state[0]
69
+ when 'R'
70
+ state_s = 'ok'
71
+ running = 1
72
+ when 'S'
73
+ state_s = 'ok'
74
+ when 'I'
75
+ state_s = 'warning'
76
+ when 'T', 'U', 'Z'
77
+ state_s = 'critical'
78
+ else
79
+ state_s = 'unknown'
80
+ end
81
+ report(
82
+ service: "proc #{pid}-#{start_s}/rss",
83
+ state: state_s.to_s,
84
+ metric: rss.to_f,
85
+ description: command,
86
+ )
87
+ report(
88
+ service: "proc #{pid}-#{start_s}/vsize",
89
+ state: state_s.to_s,
90
+ metric: vsize.to_f,
91
+ description: command,
92
+ )
93
+ report(
94
+ service: "proc #{pid}-#{start_s}/running",
95
+ state: state_s.to_s,
96
+ metric: running.to_f,
97
+ description: command,
98
+ )
99
+ report(
100
+ service: "proc #{pid}-#{start_s}/cputime",
101
+ state: state_s.to_s,
102
+ metric: cputime_seconds,
103
+ description: command,
104
+ )
74
105
  end
75
- report(
76
- :service => "proc #{pid}-#{start_s}/rss",
77
- :state => state_s.to_s,
78
- :metric => rss.to_f,
79
- :description => command,
80
- )
81
- report(
82
- :service => "proc #{pid}-#{start_s}/vsize",
83
- :state => state_s.to_s,
84
- :metric => vsize.to_f,
85
- :description => command,
86
- )
87
- report(
88
- :service => "proc #{pid}-#{start_s}/running",
89
- :state => state_s.to_s,
90
- :metric => running.to_f,
91
- :description => command,
92
- )
93
- report(
94
- :service => "proc #{pid}-#{start_s}/cputime",
95
- :state => state_s.to_s,
96
- :metric => cputime_seconds,
97
- :description => command,
98
- )
99
106
  end
100
- end
101
- end
102
107
 
103
- def tick
104
- @check.call
108
+ def tick
109
+ @check.call
110
+ end
111
+ end
105
112
  end
106
113
  end
107
114
 
data/bin/riemann-varnish CHANGED
@@ -1,52 +1,59 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ Process.setproctitle($PROGRAM_NAME)
2
5
 
3
6
  # Reports varnish stats to Riemann.
4
7
 
5
8
  require 'open3'
6
- require File.expand_path('../../lib/riemann/tools', __FILE__)
7
-
8
- class Riemann::Tools::Varnish
9
- include Riemann::Tools
10
-
11
- opt :varnish_host, "Varnish hostname", :default => `hostname`.chomp
12
-
13
- def initialize
14
- cmd = 'varnishstat -V'
15
- Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
16
- @ver = /varnishstat \(varnish-(\d+)/.match(stderr.read)[1].to_i
17
- end
18
-
19
- if @ver >= 4
20
- @vstats = [ "MAIN.sess_conn",
21
- "MAIN.sess_drop ",
22
- "MAIN.client_req",
23
- "MAIN.cache_hit",
24
- "MAIN.cache_miss" ]
25
- else
26
- @vstats = [ "client_conn",
27
- "client_drop",
28
- "client_req",
29
- "cache_hit",
30
- "cache_miss" ]
31
- end
32
- end
33
-
34
- def tick
35
- if @ver >= 4
36
- stats = `varnishstat -1 -f #{@vstats.join(" -f ")}`
37
- else
38
- stats = `varnishstat -1 -f #{@vstats.join(",")}`
39
- end
40
- stats.each_line do |stat|
41
- m = stat.split()
42
- report(
43
- :host => opts[:varnish_host].dup,
44
- :service => "varnish #{m[0]}",
45
- :metric => m[1].to_f,
46
- :state => "ok",
47
- :description => "#{m[3..-1].join(' ')}",
48
- :tags => ["varnish"]
49
- )
9
+ require File.expand_path('../lib/riemann/tools', __dir__)
10
+
11
+ module Riemann
12
+ module Tools
13
+ class Varnish
14
+ include Riemann::Tools
15
+
16
+ opt :varnish_host, 'Varnish hostname', default: `hostname`.chomp
17
+
18
+ def initialize
19
+ cmd = 'varnishstat -V'
20
+ Open3.popen3(cmd) do |_stdin, _stdout, stderr, _wait_thr|
21
+ @ver = /varnishstat \(varnish-(\d+)/.match(stderr.read)[1].to_i
22
+ end
23
+
24
+ @vstats = if @ver >= 4
25
+ ['MAIN.sess_conn',
26
+ 'MAIN.sess_drop ',
27
+ 'MAIN.client_req',
28
+ 'MAIN.cache_hit',
29
+ 'MAIN.cache_miss',]
30
+ else
31
+ %w[client_conn
32
+ client_drop
33
+ client_req
34
+ cache_hit
35
+ cache_miss]
36
+ end
37
+ end
38
+
39
+ def tick
40
+ stats = if @ver >= 4
41
+ `varnishstat -1 -f #{@vstats.join(' -f ')}`
42
+ else
43
+ `varnishstat -1 -f #{@vstats.join(',')}`
44
+ end
45
+ stats.each_line do |stat|
46
+ m = stat.split
47
+ report(
48
+ host: opts[:varnish_host].dup,
49
+ service: "varnish #{m[0]}",
50
+ metric: m[1].to_f,
51
+ state: 'ok',
52
+ description: m[3..].join(' ').to_s,
53
+ tags: ['varnish'],
54
+ )
55
+ end
56
+ end
50
57
  end
51
58
  end
52
59
  end
@@ -1,40 +1,45 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ Process.setproctitle($PROGRAM_NAME)
2
5
 
3
6
  # Gathers zookeeper STATS and submits them to Riemann.
4
7
 
5
- require File.expand_path('../../lib/riemann/tools', __FILE__)
6
-
7
- class Riemann::Tools::Zookeeper
8
- include Riemann::Tools
9
- require 'socket'
10
-
11
- opt :zookeeper_host, "Zookeeper hostname", :default => 'localhost'
12
- opt :zookeeper_port, "Zookeeper port", :default => 2181
13
-
14
- def tick
15
- sock = TCPSocket.new(opts[:zookeeper_host], opts[:zookeeper_port])
16
- sock.sync = true
17
- sock.print("mntr")
18
- sock.flush
19
-
20
-
21
- data = {}
22
- while true
23
- stats = sock.gets
24
-
25
- break if stats.nil?
26
-
27
- m = stats.match /^(\w+)\t+(.*)/
28
-
29
- report(
30
- :host => opts[ :zookeeper_host].dup,
31
- :service => "zookeeper #{m[1]}",
32
- :metric => m[2].to_f,
33
- :state => 'ok',
34
- :tags => ['zookeeper']
35
- )
36
- end
37
- sock.close
8
+ require File.expand_path('../lib/riemann/tools', __dir__)
9
+
10
+ module Riemann
11
+ module Tools
12
+ class Zookeeper
13
+ include Riemann::Tools
14
+ require 'socket'
15
+
16
+ opt :zookeeper_host, 'Zookeeper hostname', default: 'localhost'
17
+ opt :zookeeper_port, 'Zookeeper port', default: 2181
18
+
19
+ def tick
20
+ sock = TCPSocket.new(opts[:zookeeper_host], opts[:zookeeper_port])
21
+ sock.sync = true
22
+ sock.print('mntr')
23
+ sock.flush
24
+
25
+ loop do
26
+ stats = sock.gets
27
+
28
+ break if stats.nil?
29
+
30
+ m = stats.match(/^(\w+)\t+(.*)/)
31
+
32
+ report(
33
+ host: opts[:zookeeper_host].dup,
34
+ service: "zookeeper #{m[1]}",
35
+ metric: m[2].to_f,
36
+ state: 'ok',
37
+ tags: ['zookeeper'],
38
+ )
39
+ end
40
+ sock.close
41
+ end
42
+ end
38
43
  end
39
44
  end
40
45