riemann-tools 1.1.1 → 1.4.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/workflows/ci.yml +2 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +60 -2
- data/Rakefile +17 -3
- data/bin/riemann-apache-status +1 -106
- data/bin/riemann-bench +2 -70
- data/bin/riemann-cloudant +1 -56
- data/bin/riemann-consul +1 -106
- data/bin/riemann-dir-files-count +1 -55
- data/bin/riemann-dir-space +1 -55
- data/bin/riemann-diskstats +1 -92
- data/bin/riemann-fd +2 -81
- data/bin/riemann-freeswitch +2 -119
- data/bin/riemann-haproxy +1 -58
- data/bin/riemann-health +0 -2
- data/bin/riemann-kvminstance +2 -22
- data/bin/riemann-md +8 -0
- data/bin/riemann-memcached +1 -37
- data/bin/riemann-net +0 -2
- data/bin/riemann-nginx-status +1 -85
- data/bin/riemann-ntp +0 -2
- data/bin/riemann-portcheck +1 -44
- data/bin/riemann-proc +1 -108
- data/bin/riemann-varnish +1 -54
- data/bin/riemann-wrapper +113 -0
- data/bin/riemann-zookeeper +1 -39
- data/bin/riemann-zpool +8 -0
- data/lib/riemann/tools/apache_status.rb +107 -0
- data/lib/riemann/tools/bench.rb +72 -0
- data/lib/riemann/tools/cloudant.rb +57 -0
- data/lib/riemann/tools/consul_health.rb +107 -0
- data/lib/riemann/tools/dir_files_count.rb +56 -0
- data/lib/riemann/tools/dir_space.rb +56 -0
- data/lib/riemann/tools/diskstats.rb +94 -0
- data/lib/riemann/tools/fd.rb +81 -0
- data/lib/riemann/tools/freeswitch.rb +119 -0
- data/lib/riemann/tools/haproxy.rb +59 -0
- data/lib/riemann/tools/health.rb +150 -19
- data/lib/riemann/tools/kvm.rb +23 -0
- data/lib/riemann/tools/md.rb +35 -0
- data/lib/riemann/tools/mdstat_parser.tab.rb +340 -0
- data/lib/riemann/tools/memcached.rb +38 -0
- data/lib/riemann/tools/net.rb +2 -1
- data/lib/riemann/tools/nginx_status.rb +86 -0
- data/lib/riemann/tools/ntp.rb +1 -0
- data/lib/riemann/tools/portcheck.rb +45 -0
- data/lib/riemann/tools/proc.rb +109 -0
- data/lib/riemann/tools/riemann_client_wrapper.rb +43 -0
- data/lib/riemann/tools/uptime_parser.tab.rb +323 -0
- data/lib/riemann/tools/varnish.rb +55 -0
- data/lib/riemann/tools/version.rb +1 -1
- data/lib/riemann/tools/zookeeper.rb +40 -0
- data/lib/riemann/tools/zpool.rb +40 -0
- data/lib/riemann/tools.rb +2 -20
- data/riemann-tools.gemspec +10 -1
- data/tools/riemann-aws/Rakefile +6 -9
- data/tools/riemann-aws/bin/riemann-aws-billing +2 -87
- data/tools/riemann-aws/bin/riemann-aws-rds-status +2 -62
- data/tools/riemann-aws/bin/riemann-aws-sqs-status +2 -44
- data/tools/riemann-aws/bin/riemann-aws-status +2 -77
- data/tools/riemann-aws/bin/riemann-elb-metrics +2 -162
- data/tools/riemann-aws/bin/riemann-s3-list +2 -81
- data/tools/riemann-aws/bin/riemann-s3-status +2 -96
- data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +87 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/elb_metrics.rb +163 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +63 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/s3_list.rb +82 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +97 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +45 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +74 -0
- data/tools/riemann-chronos/Rakefile +6 -9
- data/tools/riemann-chronos/bin/riemann-chronos +1 -154
- data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +157 -0
- data/tools/riemann-docker/Rakefile +5 -8
- data/tools/riemann-docker/bin/riemann-docker +2 -200
- data/tools/riemann-docker/lib/riemann/tools/docker.rb +200 -0
- data/tools/riemann-elasticsearch/Rakefile +6 -9
- data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +1 -167
- data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +170 -0
- data/tools/riemann-marathon/Rakefile +6 -9
- data/tools/riemann-marathon/bin/riemann-marathon +1 -156
- data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +159 -0
- data/tools/riemann-mesos/Rakefile +6 -9
- data/tools/riemann-mesos/bin/riemann-mesos +1 -139
- data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +142 -0
- data/tools/riemann-munin/Rakefile +5 -8
- data/tools/riemann-munin/bin/riemann-munin +1 -36
- data/tools/riemann-munin/lib/riemann/tools/munin.rb +37 -0
- data/tools/riemann-rabbitmq/Rakefile +6 -9
- data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +1 -266
- data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +269 -0
- data/tools/riemann-riak/Rakefile +5 -8
- data/tools/riemann-riak/bin/riemann-riak +1 -316
- data/tools/riemann-riak/bin/riemann-riak-keys +0 -1
- data/tools/riemann-riak/bin/riemann-riak-ring +0 -1
- data/tools/riemann-riak/lib/riemann/tools/riak.rb +317 -0
- metadata +64 -10
- data/.travis.yml +0 -31
- data/tools/riemann-riak/riak_status/key_count.erl +0 -13
- data/tools/riemann-riak/riak_status/riak_status.rb +0 -152
- data/tools/riemann-riak/riak_status/ringready.erl +0 -9
data/bin/riemann-diskstats
CHANGED
|
@@ -2,98 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
|
-
require 'rubygems'
|
|
6
|
-
require 'riemann/tools'
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
module Tools
|
|
10
|
-
class Diskstats
|
|
11
|
-
include Riemann::Tools
|
|
12
|
-
|
|
13
|
-
opt :devices, 'Devices to monitor', type: :strings, default: nil
|
|
14
|
-
opt :ignore_devices, 'Devices to ignore', type: :strings, default: nil
|
|
15
|
-
|
|
16
|
-
def initialize
|
|
17
|
-
@old_state = nil
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def state
|
|
21
|
-
f = File.read('/proc/diskstats')
|
|
22
|
-
state = f.split("\n").reject { |d| d =~ /(ram|loop)/ }.each_with_object({}) do |line, s|
|
|
23
|
-
next unless line =~ /^(?:\s+\d+){2}\s+([\w\d\-]+) (.*)$/
|
|
24
|
-
|
|
25
|
-
dev = Regexp.last_match(1)
|
|
26
|
-
|
|
27
|
-
['reads reqs',
|
|
28
|
-
'reads merged',
|
|
29
|
-
'reads sector',
|
|
30
|
-
'reads time',
|
|
31
|
-
'writes reqs',
|
|
32
|
-
'writes merged',
|
|
33
|
-
'writes sector',
|
|
34
|
-
'writes time',
|
|
35
|
-
'io reqs',
|
|
36
|
-
'io time',
|
|
37
|
-
'io weighted',].map do |service|
|
|
38
|
-
"#{dev} #{service}"
|
|
39
|
-
end.zip( # rubocop:disable Style/MultilineBlockChain
|
|
40
|
-
Regexp.last_match(2).split(/\s+/).map(&:to_i),
|
|
41
|
-
).each do |service, value|
|
|
42
|
-
s[service] = value
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Filter interfaces
|
|
47
|
-
if (is = opts[:devices])
|
|
48
|
-
state = state.select do |service, _value|
|
|
49
|
-
is.include? service.split(' ').first
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
if (ign = opts[:ignore_devices])
|
|
54
|
-
state = state.reject do |service, _value|
|
|
55
|
-
ign.include? service.split(' ').first
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
state
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def tick
|
|
63
|
-
state = self.state
|
|
64
|
-
|
|
65
|
-
if @old_state
|
|
66
|
-
state.each do |service, metric|
|
|
67
|
-
if service =~ /io reqs$/
|
|
68
|
-
report(
|
|
69
|
-
service: "diskstats #{service}",
|
|
70
|
-
metric: metric,
|
|
71
|
-
state: 'ok',
|
|
72
|
-
)
|
|
73
|
-
else
|
|
74
|
-
delta = metric - @old_state[service]
|
|
75
|
-
|
|
76
|
-
report(
|
|
77
|
-
service: "diskstats #{service}",
|
|
78
|
-
metric: (delta.to_f / opts[:interval]),
|
|
79
|
-
state: 'ok',
|
|
80
|
-
)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
next unless service =~ /io time$/
|
|
84
|
-
|
|
85
|
-
report(
|
|
86
|
-
service: "diskstats #{service.gsub(/time/, 'util')}",
|
|
87
|
-
metric: (delta.to_f / (opts[:interval] * 1000)),
|
|
88
|
-
state: 'ok',
|
|
89
|
-
)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
@old_state = state
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
6
|
+
require 'riemann/tools/diskstats'
|
|
98
7
|
|
|
99
8
|
Riemann::Tools::Diskstats.run
|
data/bin/riemann-fd
CHANGED
|
@@ -3,85 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
# By default reports the total system fd usage, can also report usage of individual processes
|
|
6
|
+
require 'riemann/tools/fd'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module Riemann
|
|
12
|
-
module Tools
|
|
13
|
-
class Health
|
|
14
|
-
include Riemann::Tools
|
|
15
|
-
|
|
16
|
-
opt :fd_sys_warning, 'open file descriptor threshold for system', default: 800
|
|
17
|
-
opt :fd_sys_critical, 'open file descriptor critical threshold for system', default: 900
|
|
18
|
-
opt :fd_proc_warning, 'open file descriptor threshold for process', default: 800
|
|
19
|
-
opt :fd_proc_critical, 'open file descriptor critical threshold for process', default: 900
|
|
20
|
-
opt :processes, 'list of processes to measure fd usage in addition to system total', type: :ints
|
|
21
|
-
|
|
22
|
-
def initialize
|
|
23
|
-
@limits = {
|
|
24
|
-
fd: { critical: opts[:fd_sys_critical], warning: opts[:fd_sys_warning] },
|
|
25
|
-
process: { critical: opts[:fd_proc_critical], warning: opts[:fd_proc_warning] },
|
|
26
|
-
}
|
|
27
|
-
ostype = `uname -s`.chomp.downcase
|
|
28
|
-
case ostype
|
|
29
|
-
when 'freebsd'
|
|
30
|
-
@fd = method :freebsd_fd
|
|
31
|
-
else
|
|
32
|
-
puts "WARNING: OS '#{ostype}' not explicitly supported. Falling back to Linux" unless ostype == 'linux'
|
|
33
|
-
@fd = method :linux_fd
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def alert(service, state, metric, description)
|
|
38
|
-
report(
|
|
39
|
-
service: service.to_s,
|
|
40
|
-
state: state.to_s,
|
|
41
|
-
metric: metric.to_f,
|
|
42
|
-
description: description,
|
|
43
|
-
)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def freebsd_fd
|
|
47
|
-
sys_used = Integer(`sysctl -n kern.openfiles`)
|
|
48
|
-
if sys_used > @limits[:fd][:critical]
|
|
49
|
-
alert 'fd sys', :critical, sys_used, "system is using #{sys_used} fds"
|
|
50
|
-
elsif sys_used > @limits[:fd][:warning]
|
|
51
|
-
alert 'fd sys', :warning, sys_used, "system is using #{sys_used} fds"
|
|
52
|
-
else
|
|
53
|
-
alert 'fd sys', :ok, sys_used, "system is using #{sys_used} fds"
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def linux_fd
|
|
58
|
-
sys_used = Integer(`lsof | wc -l`)
|
|
59
|
-
if sys_used > @limits[:fd][:critical]
|
|
60
|
-
alert 'fd sys', :critical, sys_used, "system is using #{sys_used} fds"
|
|
61
|
-
elsif sys_used > @limits[:fd][:warning]
|
|
62
|
-
alert 'fd sys', :warning, sys_used, "system is using #{sys_used} fds"
|
|
63
|
-
else
|
|
64
|
-
alert 'fd sys', :ok, sys_used, "system is using #{sys_used} fds"
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
opts[:processes]&.each do |process|
|
|
68
|
-
used = Integer(`lsof -p #{process} | wc -l`)
|
|
69
|
-
name, _pid = `ps axo comm,pid | grep -w #{process}`.split
|
|
70
|
-
if used > @limits[:process][:critical]
|
|
71
|
-
alert "fd #{name} #{process}", :critical, used, "process #{name} #{process} is using #{used} fds"
|
|
72
|
-
elsif used > @limits[:process][:warning]
|
|
73
|
-
alert "fd #{name} #{process}", :warning, used, "process #{name} #{process} is using #{used} fds"
|
|
74
|
-
else
|
|
75
|
-
alert "fd #{name} #{process}", :ok, used, "process #{name} #{process} is using #{used} fds"
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def tick
|
|
81
|
-
@fd.call
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
Riemann::Tools::Health.run
|
|
8
|
+
Riemann::Tools::Fd.run
|
data/bin/riemann-freeswitch
CHANGED
|
@@ -1,125 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require 'English'
|
|
5
|
-
|
|
6
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
7
5
|
|
|
8
|
-
require
|
|
9
|
-
|
|
10
|
-
module Riemann
|
|
11
|
-
module Tools
|
|
12
|
-
class FreeSWITCH
|
|
13
|
-
include Riemann::Tools
|
|
14
|
-
|
|
15
|
-
opt :calls_warning, 'Calls warning threshold', default: 100
|
|
16
|
-
opt :calls_critical, 'Calls critical threshold', default: 300
|
|
17
|
-
opt :pid_file, 'FreeSWITCH daemon pidfile', type: String, default: '/var/run/freeswitch/freeswitch.pid'
|
|
18
|
-
|
|
19
|
-
def initialize
|
|
20
|
-
@limits = {
|
|
21
|
-
calls: { critical: opts[:calls_critical], warning: opts[:calls_warning] },
|
|
22
|
-
}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def dead_proc?(pid)
|
|
26
|
-
Process.getpgid(pid)
|
|
27
|
-
false
|
|
28
|
-
rescue Errno::ESRCH
|
|
29
|
-
true
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def alert(service, state, metric, description)
|
|
33
|
-
report(
|
|
34
|
-
service: service.to_s,
|
|
35
|
-
state: state.to_s,
|
|
36
|
-
metric: metric.to_f,
|
|
37
|
-
description: description,
|
|
38
|
-
)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def exec_with_timeout(cmd, timeout)
|
|
42
|
-
pid = Process.spawn(cmd, { %i[err out] => :close, :pgroup => true })
|
|
43
|
-
begin
|
|
44
|
-
Timeout.timeout(timeout) do
|
|
45
|
-
Process.waitpid(pid, 0)
|
|
46
|
-
$CHILD_STATUS.exitstatus.zero?
|
|
47
|
-
end
|
|
48
|
-
rescue Timeout::Error
|
|
49
|
-
Process.kill(15, -Process.getpgid(pid))
|
|
50
|
-
puts "Killed pid: #{pid}"
|
|
51
|
-
false
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def tick
|
|
56
|
-
# Determine how many current calls I have according to FreeSWITCH
|
|
57
|
-
fs_calls = `fs_cli -x "show calls count"| grep -Po '^\\d+'`.to_i
|
|
58
|
-
|
|
59
|
-
# Determine how many current channels I have according to FreeSWITCH
|
|
60
|
-
fs_channels = `fs_cli -x "show channels count"| grep -Po '^\\d+'`.to_i
|
|
61
|
-
|
|
62
|
-
# Determine how many conferences I have according to FreeSWITCH
|
|
63
|
-
fs_conferences = `fs_cli -x "conference list"| grep -Pco '^Conference'`.to_i
|
|
64
|
-
|
|
65
|
-
# Try to read pidfile. If it fails use Devil's dummy PID
|
|
66
|
-
begin
|
|
67
|
-
fs_pid = File.read(opts[:pid_file]).to_i
|
|
68
|
-
rescue StandardError
|
|
69
|
-
puts "Couldn't read pidfile: #{opts[:pid_file]}"
|
|
70
|
-
fs_pid = -666
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
fs_threads = fs_pid.positive? ? `ps huH p #{fs_pid} | wc -l`.to_i : 0
|
|
74
|
-
|
|
75
|
-
# Submit calls to riemann
|
|
76
|
-
if fs_calls > @limits[:calls][:critical]
|
|
77
|
-
alert 'FreeSWITCH current calls', :critical, fs_calls, "Number of calls are #{fs_calls}"
|
|
78
|
-
elsif fs_calls > @limits[:calls][:warning]
|
|
79
|
-
alert 'FreeSWITCH current calls', :warning, fs_calls, "Number of calls are #{fs_calls}"
|
|
80
|
-
else
|
|
81
|
-
alert 'FreeSWITCH current calls', :ok, fs_calls, "Number of calls are #{fs_calls}"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# Submit channels to riemann
|
|
85
|
-
if fs_channels > @limits[:calls][:critical]
|
|
86
|
-
alert 'FreeSWITCH current channels', :critical, fs_channels, "Number of channels are #{fs_channels}"
|
|
87
|
-
elsif fs_channels > @limits[:calls][:warning]
|
|
88
|
-
alert 'FreeSWITCH current channels', :warning, fs_channels, "Number of channels are #{fs_channels}"
|
|
89
|
-
else
|
|
90
|
-
alert 'FreeSWITCH current channels', :ok, fs_channels, "Number of channels are #{fs_channels}"
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Submit conferences to riemann
|
|
94
|
-
if fs_conferences > @limits[:calls][:critical]
|
|
95
|
-
alert 'FreeSWITCH current conferences', :critical, fs_conferences,
|
|
96
|
-
"Number of conferences are #{fs_conferences}"
|
|
97
|
-
elsif fs_conferences > @limits[:calls][:warning]
|
|
98
|
-
alert 'FreeSWITCH current conferences', :warning, fs_conferences,
|
|
99
|
-
"Number of conferences are #{fs_conferences}"
|
|
100
|
-
else
|
|
101
|
-
alert 'FreeSWITCH current conferences', :ok, fs_conferences, "Number of conferences are #{fs_conferences}"
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# Submit threads to riemann
|
|
105
|
-
alert 'FreeSWITCH current threads', :ok, fs_threads, "Number of threads are #{fs_threads}" if fs_threads
|
|
106
|
-
|
|
107
|
-
# Submit status to riemann
|
|
108
|
-
if dead_proc?(fs_pid)
|
|
109
|
-
alert 'FreeSWITCH status', :critical, -1, 'FreeSWITCH service status: not running'
|
|
110
|
-
else
|
|
111
|
-
alert 'FreeSWITCH status', :ok, nil, 'FreeSWITCH service status: running'
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
# Submit CLI status to riemann using timeout in case it's unresponsive
|
|
115
|
-
if exec_with_timeout('fs_cli -x status', 2)
|
|
116
|
-
alert 'FreeSWITCH CLI status', :ok, nil, 'FreeSWITCH CLI status: responsive'
|
|
117
|
-
else
|
|
118
|
-
alert 'FreeSWITCH CLI status', :critical, -1, 'FreeSWITCH CLI status: not responding'
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|
|
6
|
+
require 'riemann/tools/freeswitch'
|
|
124
7
|
|
|
125
|
-
Riemann::Tools::
|
|
8
|
+
Riemann::Tools::Freeswitch.run
|
data/bin/riemann-haproxy
CHANGED
|
@@ -3,63 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require File.expand_path('../lib/riemann/tools', __dir__)
|
|
9
|
-
|
|
10
|
-
module Riemann
|
|
11
|
-
module Tools
|
|
12
|
-
class Haproxy
|
|
13
|
-
include Riemann::Tools
|
|
14
|
-
require 'net/http'
|
|
15
|
-
require 'csv'
|
|
16
|
-
|
|
17
|
-
opt :stats_url, 'Full url to haproxy stats (eg: https://user:password@host.com:9999/stats)', required: true,
|
|
18
|
-
type: :string
|
|
19
|
-
|
|
20
|
-
def initialize
|
|
21
|
-
@uri = URI("#{opts[:stats_url]};csv")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def tick
|
|
25
|
-
csv.each do |row|
|
|
26
|
-
row = row.to_hash
|
|
27
|
-
ns = "haproxy #{row['pxname']} #{row['svname']}"
|
|
28
|
-
row.each do |property, metric|
|
|
29
|
-
next if property.nil? || property == 'pxname' || property == 'svname'
|
|
30
|
-
|
|
31
|
-
report(
|
|
32
|
-
host: @uri.host,
|
|
33
|
-
service: "#{ns} #{property}",
|
|
34
|
-
metric: metric.to_f,
|
|
35
|
-
tags: ['haproxy'],
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
report(
|
|
40
|
-
host: @uri.host,
|
|
41
|
-
service: "#{ns} state",
|
|
42
|
-
state: (%w[UP OPEN].include?(row['status']) ? 'ok' : 'critical'),
|
|
43
|
-
tags: ['haproxy'],
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def csv
|
|
49
|
-
http = Net::HTTP.new(@uri.host, @uri.port)
|
|
50
|
-
http.use_ssl = true if @uri.scheme == 'https'
|
|
51
|
-
http.start do |h|
|
|
52
|
-
get = Net::HTTP::Get.new(@uri.request_uri)
|
|
53
|
-
unless @uri.userinfo.nil?
|
|
54
|
-
userinfo = @uri.userinfo.split(':')
|
|
55
|
-
get.basic_auth userinfo[0], userinfo[1]
|
|
56
|
-
end
|
|
57
|
-
h.request get
|
|
58
|
-
end
|
|
59
|
-
CSV.parse(http.body.split('# ')[1], { headers: true })
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
6
|
+
require 'riemann/tools/haproxy'
|
|
64
7
|
|
|
65
8
|
Riemann::Tools::Haproxy.run
|
data/bin/riemann-health
CHANGED
data/bin/riemann-kvminstance
CHANGED
|
@@ -3,26 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
require
|
|
6
|
+
require 'riemann/tools/kvm'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
module Tools
|
|
10
|
-
class KVM
|
|
11
|
-
include Riemann::Tools
|
|
12
|
-
|
|
13
|
-
def tick
|
|
14
|
-
# determine how many instances I have according to libvirt
|
|
15
|
-
kvm_instances = `LANG=C virsh list | grep -c running`
|
|
16
|
-
|
|
17
|
-
# submit them to riemann
|
|
18
|
-
report(
|
|
19
|
-
service: 'KVM Running VMs',
|
|
20
|
-
metric: kvm_instances.to_i,
|
|
21
|
-
state: 'info',
|
|
22
|
-
)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
Riemann::Tools::KVM.run
|
|
8
|
+
Riemann::Tools::Kvm.run
|
data/bin/riemann-md
ADDED
data/bin/riemann-memcached
CHANGED
|
@@ -3,42 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require File.expand_path('../lib/riemann/tools', __dir__)
|
|
9
|
-
|
|
10
|
-
module Riemann
|
|
11
|
-
module Tools
|
|
12
|
-
class Memcached
|
|
13
|
-
include Riemann::Tools
|
|
14
|
-
require 'socket'
|
|
15
|
-
|
|
16
|
-
opt :memcached_host, 'Memcached hostname', default: 'localhost'
|
|
17
|
-
opt :memcached_port, 'Memcached port', default: 11_211
|
|
18
|
-
|
|
19
|
-
def tick
|
|
20
|
-
sock = TCPSocket.new(opts[:memcached_host], opts[:memcached_port])
|
|
21
|
-
sock.print("stats\r\n")
|
|
22
|
-
sock.flush
|
|
23
|
-
stats = sock.gets
|
|
24
|
-
|
|
25
|
-
loop do
|
|
26
|
-
stats = sock.gets
|
|
27
|
-
break if stats.strip == 'END'
|
|
28
|
-
|
|
29
|
-
m = stats.match(/STAT (\w+) (\S+)/)
|
|
30
|
-
report(
|
|
31
|
-
host: opts[:memcached_host].dup,
|
|
32
|
-
service: "memcached #{m[1]}",
|
|
33
|
-
metric: m[2].to_f,
|
|
34
|
-
state: 'ok',
|
|
35
|
-
tags: ['memcached'],
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
sock.close
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
6
|
+
require 'riemann/tools/memcached'
|
|
43
7
|
|
|
44
8
|
Riemann::Tools::Memcached.run
|
data/bin/riemann-net
CHANGED
data/bin/riemann-nginx-status
CHANGED
|
@@ -3,90 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
# See http://wiki.nginx.org/HttpStubStatusModule for configuring Nginx appropriately
|
|
8
|
-
|
|
9
|
-
require File.expand_path('../lib/riemann/tools', __dir__)
|
|
10
|
-
|
|
11
|
-
module Riemann
|
|
12
|
-
module Tools
|
|
13
|
-
class NginxStatus
|
|
14
|
-
include Riemann::Tools
|
|
15
|
-
require 'net/http'
|
|
16
|
-
require 'uri'
|
|
17
|
-
|
|
18
|
-
opt :uri, 'Nginx Stub Status URI', default: 'http://localhost:8080/nginx_status'
|
|
19
|
-
opt :checks, 'Which metrics to report.', type: :strings,
|
|
20
|
-
default: %w[active accepted handled requests reading writing waiting]
|
|
21
|
-
opt :active_warning, 'Active connections warning threshold', default: 0
|
|
22
|
-
opt :active_critical, 'Active connections critical threshold', default: 0
|
|
23
|
-
opt :reading_warning, 'Reading connections warning threshold', default: 0
|
|
24
|
-
opt :reading_critical, 'Reading connections critical threshold', default: 0
|
|
25
|
-
opt :writing_warning, 'Writing connections warning threshold', default: 0
|
|
26
|
-
opt :writing_critical, 'Writing connections critical threshold', default: 0
|
|
27
|
-
opt :waiting_warning, 'Waiting connections warning threshold', default: 0
|
|
28
|
-
opt :waiting_critical, 'Waiting connections critical threshold', default: 0
|
|
29
|
-
|
|
30
|
-
def initialize
|
|
31
|
-
@uri = URI.parse(opts[:uri])
|
|
32
|
-
|
|
33
|
-
# sample response:
|
|
34
|
-
#
|
|
35
|
-
# Active connections: 1
|
|
36
|
-
# server accepts handled requests
|
|
37
|
-
# 39 39 39
|
|
38
|
-
# Reading: 0 Writing: 1 Waiting: 0
|
|
39
|
-
@keys = %w[active accepted handled requests reading writing waiting]
|
|
40
|
-
@re = /Active connections: (\d+) \n.+\n (\d+) (\d+) (\d+) \nReading: (\d+) Writing: (\d+) Waiting: (\d+)/m
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def state(key, value)
|
|
44
|
-
if opts.key? "#{key}_critical".to_sym
|
|
45
|
-
critical_threshold = opts["#{key}_critical".to_sym]
|
|
46
|
-
return 'critical' if critical_threshold.positive? && (value >= critical_threshold)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
if opts.key? "#{key}_warning".to_sym
|
|
50
|
-
warning_threshold = opts["#{key}_warning".to_sym]
|
|
51
|
-
return 'warning' if warning_threshold.positive? && (value >= warning_threshold)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
'ok'
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def tick
|
|
58
|
-
response = nil
|
|
59
|
-
begin
|
|
60
|
-
response = Net::HTTP.get(@uri)
|
|
61
|
-
rescue StandardError => e
|
|
62
|
-
report(
|
|
63
|
-
service: 'nginx health',
|
|
64
|
-
state: 'critical',
|
|
65
|
-
description: "Connection error: #{e.class} - #{e.message}",
|
|
66
|
-
)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
return if response.nil?
|
|
70
|
-
|
|
71
|
-
report(
|
|
72
|
-
service: 'nginx health',
|
|
73
|
-
state: 'ok',
|
|
74
|
-
description: 'Nginx status connection ok',
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
values = @re.match(response).to_a[1, 7].map(&:to_i)
|
|
78
|
-
|
|
79
|
-
@keys.zip(values).each do |key, value|
|
|
80
|
-
report({
|
|
81
|
-
service: "nginx #{key}",
|
|
82
|
-
metric: value,
|
|
83
|
-
state: state(key, value),
|
|
84
|
-
tags: ['nginx'],
|
|
85
|
-
})
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
6
|
+
require 'riemann/tools/nginx_status'
|
|
91
7
|
|
|
92
8
|
Riemann::Tools::NginxStatus.run
|
data/bin/riemann-ntp
CHANGED
data/bin/riemann-portcheck
CHANGED
|
@@ -3,49 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
# (c) Max Voit 2017
|
|
8
|
-
|
|
9
|
-
require File.expand_path('../lib/riemann/tools', __dir__)
|
|
10
|
-
|
|
11
|
-
module Riemann
|
|
12
|
-
module Tools
|
|
13
|
-
class Portcheck
|
|
14
|
-
include Riemann::Tools
|
|
15
|
-
require 'socket'
|
|
16
|
-
|
|
17
|
-
opt :hostname, 'Host, defaults to localhost', default: `hostname`.chomp
|
|
18
|
-
opt :ports, "List of ports to check, e.g. '-r 80 443'", type: :ints
|
|
19
|
-
|
|
20
|
-
def initialize
|
|
21
|
-
@hostname = opts.fetch(:hostname)
|
|
22
|
-
@ports = opts.fetch(:ports)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def tick
|
|
26
|
-
@ports.each do |thisport|
|
|
27
|
-
# try opening tcp connection with 5s timeout;
|
|
28
|
-
# if this fails, the port is considered closed
|
|
29
|
-
portopen = begin
|
|
30
|
-
Socket.tcp(@hostname, thisport, connect_timeout: 5) { true }
|
|
31
|
-
rescue StandardError
|
|
32
|
-
false
|
|
33
|
-
end
|
|
34
|
-
state = if portopen
|
|
35
|
-
'ok'
|
|
36
|
-
else
|
|
37
|
-
'critical'
|
|
38
|
-
end
|
|
39
|
-
report(
|
|
40
|
-
host: @hostname.to_s,
|
|
41
|
-
service: "port #{thisport}",
|
|
42
|
-
state: state.to_s,
|
|
43
|
-
tags: ['portcheck'],
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
6
|
+
require 'riemann/tools/portcheck'
|
|
50
7
|
|
|
51
8
|
Riemann::Tools::Portcheck.run
|