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.
- checksums.yaml +5 -5
- data/.docker/Dockerfile +7 -0
- data/.docker/publish.sh +35 -0
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +42 -0
- data/.github/workflows/codeql-analysis.yml +72 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/.rubocop.yml +32 -0
- data/.travis.yml +31 -0
- data/CHANGELOG.md +430 -0
- data/Gemfile +6 -0
- data/ISSUE_TEMPLATE.md +15 -0
- data/README.markdown +13 -16
- data/Rakefile +23 -0
- data/SECURITY.md +42 -0
- data/bin/riemann-apache-status +92 -77
- data/bin/riemann-bench +54 -48
- data/bin/riemann-cloudant +44 -39
- data/bin/riemann-consul +82 -75
- data/bin/riemann-dir-files-count +53 -46
- data/bin/riemann-dir-space +53 -46
- data/bin/riemann-diskstats +78 -74
- data/bin/riemann-fd +68 -47
- data/bin/riemann-freeswitch +108 -102
- data/bin/riemann-haproxy +46 -39
- data/bin/riemann-health +4 -335
- data/bin/riemann-kvminstance +18 -12
- data/bin/riemann-memcached +35 -28
- data/bin/riemann-net +4 -103
- data/bin/riemann-nginx-status +74 -66
- data/bin/riemann-ntp +4 -32
- data/bin/riemann-portcheck +40 -30
- data/bin/riemann-proc +96 -89
- data/bin/riemann-varnish +51 -44
- data/bin/riemann-zookeeper +38 -33
- 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/utils.rb +17 -0
- data/lib/riemann/tools/version.rb +7 -0
- data/lib/riemann/tools.rb +38 -31
- data/riemann-tools.gemspec +42 -0
- data/tools/riemann-aws/LICENSE +21 -0
- data/tools/riemann-aws/README.md +54 -0
- data/tools/riemann-aws/Rakefile +37 -0
- data/tools/riemann-aws/bin/riemann-aws-billing +93 -0
- data/tools/riemann-aws/bin/riemann-aws-rds-status +68 -0
- data/tools/riemann-aws/bin/riemann-aws-sqs-status +50 -0
- data/tools/riemann-aws/bin/riemann-aws-status +83 -0
- data/tools/riemann-aws/bin/riemann-elb-metrics +168 -0
- data/tools/riemann-aws/bin/riemann-s3-list +87 -0
- data/tools/riemann-aws/bin/riemann-s3-status +102 -0
- data/tools/riemann-chronos/LICENSE +21 -0
- data/tools/riemann-chronos/README.md +10 -0
- data/tools/riemann-chronos/Rakefile +37 -0
- data/tools/riemann-chronos/bin/riemann-chronos +161 -0
- data/tools/riemann-docker/LICENSE +21 -0
- data/tools/riemann-docker/README.md +10 -0
- data/tools/riemann-docker/Rakefile +36 -0
- data/tools/riemann-docker/bin/riemann-docker +206 -0
- data/tools/riemann-elasticsearch/LICENSE +21 -0
- data/tools/riemann-elasticsearch/README.md +10 -0
- data/tools/riemann-elasticsearch/Rakefile +37 -0
- data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +174 -0
- data/tools/riemann-marathon/LICENSE +21 -0
- data/tools/riemann-marathon/README.md +10 -0
- data/tools/riemann-marathon/Rakefile +37 -0
- data/tools/riemann-marathon/bin/riemann-marathon +163 -0
- data/tools/riemann-mesos/LICENSE +21 -0
- data/tools/riemann-mesos/README.md +10 -0
- data/tools/riemann-mesos/Rakefile +37 -0
- data/tools/riemann-mesos/bin/riemann-mesos +146 -0
- data/tools/riemann-munin/LICENSE +21 -0
- data/tools/riemann-munin/README.md +10 -0
- data/tools/riemann-munin/Rakefile +36 -0
- data/tools/riemann-munin/bin/riemann-munin +43 -0
- data/tools/riemann-rabbitmq/LICENSE +21 -0
- data/tools/riemann-rabbitmq/README.md +10 -0
- data/tools/riemann-rabbitmq/Rakefile +37 -0
- data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +273 -0
- data/tools/riemann-riak/LICENSE +21 -0
- data/tools/riemann-riak/README.md +10 -0
- data/tools/riemann-riak/Rakefile +36 -0
- data/tools/riemann-riak/bin/riemann-riak +323 -0
- data/tools/riemann-riak/bin/riemann-riak-keys +13 -0
- data/tools/riemann-riak/bin/riemann-riak-ring +9 -0
- data/tools/riemann-riak/riak_status/key_count.erl +13 -0
- data/tools/riemann-riak/riak_status/riak_status.rb +152 -0
- data/tools/riemann-riak/riak_status/ringready.erl +9 -0
- 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('
|
8
|
+
require File.expand_path('../lib/riemann/tools', __dir__)
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
module Riemann
|
11
|
+
module Tools
|
12
|
+
class Proc
|
13
|
+
include Riemann::Tools
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
15
|
-
|
19
|
+
def initialize
|
20
|
+
@limits = { critical: { min: opts[:proc_min_critical], max: opts[:proc_max_critical] } }
|
16
21
|
|
17
|
-
|
22
|
+
abort 'FATAL: specify a process regular expression, see --help for usage' unless opts[:proc_regex]
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
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
|
-
|
104
|
-
|
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('
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
data/bin/riemann-zookeeper
CHANGED
@@ -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('
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
|