riemann-tools 1.1.1 → 1.2.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 +25 -2
- data/Rakefile +10 -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-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 +75 -0
- data/bin/riemann-zookeeper +1 -39
- 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/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.rb +2 -20
- data/riemann-tools.gemspec +4 -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 +57 -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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa8ed5841e8d5c02ee08180af284269ca1382e174a2dfd98b28de23227a44f61
|
|
4
|
+
data.tar.gz: 3ec31579be24a493017091aaa928b6cbd091c2d578a7d577d868ac2857e7be3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5554c62f5ce95494f5ed677ccd6933224121c9d227bc9318ec54bed380e0635f1140fbfc5cf8cd3e2ecc919fc267c12f8fb8c47da58345925c69c6d19c82a51
|
|
7
|
+
data.tar.gz: a1e3a370c5a325eb6acd59c1ad23fb3efcde20f8ff467d75a84c1e52e1f7cd2cd3102d5045bb11bfd43a43f12b01c0823c2b08f6fa75fd1e33ae50818ffa0e02
|
data/.github/workflows/ci.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
+
AllCops:
|
|
3
|
+
Exclude:
|
|
4
|
+
- lib/riemann/tools/uptime_parser.tab.rb
|
|
5
|
+
- vendor/bundle/**/*
|
|
6
|
+
Gemspec/RequiredRubyVersion:
|
|
7
|
+
Enabled: false
|
|
2
8
|
Layout/HashAlignment:
|
|
3
9
|
EnforcedHashRocketStyle: table
|
|
4
10
|
Layout/LineLength:
|
|
@@ -24,6 +30,8 @@ Naming/MethodParameterName:
|
|
|
24
30
|
- lb # load balancer
|
|
25
31
|
Style/Documentation:
|
|
26
32
|
Enabled: false
|
|
33
|
+
Style/HashSyntax:
|
|
34
|
+
EnforcedShorthandSyntax: never
|
|
27
35
|
Style/TrailingCommaInArguments:
|
|
28
36
|
EnforcedStyleForMultiline: consistent_comma
|
|
29
37
|
Style/TrailingCommaInArrayLiteral:
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.1.0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [
|
|
3
|
+
## [v1.2.0](https://github.com/riemann/riemann-tools/tree/v1.2.0) (2022-08-17)
|
|
4
4
|
|
|
5
|
-
[Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.1.
|
|
5
|
+
[Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.1.1...v1.2.0)
|
|
6
|
+
|
|
7
|
+
**Implemented enhancements:**
|
|
8
|
+
|
|
9
|
+
- Add users monitoring to riemann-health [\#226](https://github.com/riemann/riemann-tools/pull/226) ([smortex](https://github.com/smortex))
|
|
10
|
+
- Add a wrapper to run multiple tools in a single process [\#225](https://github.com/riemann/riemann-tools/pull/225) ([smortex](https://github.com/smortex))
|
|
11
|
+
- Add swap monitoring to riemann-health [\#222](https://github.com/riemann/riemann-tools/pull/222) ([smortex](https://github.com/smortex))
|
|
12
|
+
- Add uptime monitoring to riemann-health [\#218](https://github.com/riemann/riemann-tools/pull/218) ([smortex](https://github.com/smortex))
|
|
13
|
+
|
|
14
|
+
**Fixed bugs:**
|
|
15
|
+
|
|
16
|
+
- Ignore squashfs from disks usage reporting [\#228](https://github.com/riemann/riemann-tools/pull/228) ([smortex](https://github.com/smortex))
|
|
17
|
+
- Fix service name mismatch for rx/tx drop in riemann-net [\#217](https://github.com/riemann/riemann-tools/pull/217) ([smortex](https://github.com/smortex))
|
|
18
|
+
|
|
19
|
+
**Merged pull requests:**
|
|
20
|
+
|
|
21
|
+
- Normalize class names [\#224](https://github.com/riemann/riemann-tools/pull/224) ([smortex](https://github.com/smortex))
|
|
22
|
+
- Move all extra tool classes in dedicated files [\#223](https://github.com/riemann/riemann-tools/pull/223) ([smortex](https://github.com/smortex))
|
|
23
|
+
- Removed travis [\#220](https://github.com/riemann/riemann-tools/pull/220) ([jamtur01](https://github.com/jamtur01))
|
|
24
|
+
- Move all base tool classes in dedicated files [\#219](https://github.com/riemann/riemann-tools/pull/219) ([smortex](https://github.com/smortex))
|
|
25
|
+
|
|
26
|
+
## [v1.1.1](https://github.com/riemann/riemann-tools/tree/v1.1.1) (2022-07-02)
|
|
27
|
+
|
|
28
|
+
[Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.1.0...v1.1.1)
|
|
6
29
|
|
|
7
30
|
**Fixed bugs:**
|
|
8
31
|
|
data/Rakefile
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'riemann/tools/version'
|
|
4
|
-
|
|
5
4
|
require 'bundler/gem_tasks'
|
|
6
|
-
|
|
7
5
|
require 'github_changelog_generator/task'
|
|
8
6
|
|
|
9
7
|
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
|
10
8
|
config.user = 'riemann'
|
|
11
9
|
config.project = 'riemann-tools'
|
|
12
10
|
config.exclude_labels = ['skip-changelog']
|
|
13
|
-
config.future_release = Riemann::Tools::VERSION
|
|
11
|
+
config.future_release = "v#{Riemann::Tools::VERSION}"
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
desc 'Recursively build all gems'
|
|
@@ -21,3 +19,12 @@ task :rbuild do
|
|
|
21
19
|
Dir.chdir('../..')
|
|
22
20
|
end
|
|
23
21
|
end
|
|
22
|
+
|
|
23
|
+
task build: :gen_parser
|
|
24
|
+
|
|
25
|
+
desc 'Generate the uptime parser'
|
|
26
|
+
task gen_parser: 'lib/riemann/tools/uptime_parser.tab.rb'
|
|
27
|
+
|
|
28
|
+
file 'lib/riemann/tools/uptime_parser.tab.rb' => 'lib/riemann/tools/uptime_parser.y' do
|
|
29
|
+
sh 'racc -S lib/riemann/tools/uptime_parser.y'
|
|
30
|
+
end
|
data/bin/riemann-apache-status
CHANGED
|
@@ -3,111 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
# More information can be found at http://httpd.apache.org/docs/2.4/mod/mod_status.html
|
|
8
|
-
|
|
9
|
-
# Removes whitespace from 'Total Accesses' and 'Total kBytes' for output to graphite
|
|
10
|
-
|
|
11
|
-
require File.expand_path('../lib/riemann/tools', __dir__)
|
|
12
|
-
|
|
13
|
-
module Riemann
|
|
14
|
-
module Tools
|
|
15
|
-
class ApacheStatus
|
|
16
|
-
include Riemann::Tools
|
|
17
|
-
require 'net/http'
|
|
18
|
-
require 'uri'
|
|
19
|
-
|
|
20
|
-
opt :uri, 'Apache Server Status URI', default: 'http://localhost/server-status'
|
|
21
|
-
|
|
22
|
-
def initialize
|
|
23
|
-
@uri = "#{URI.parse(opts[:uri])}?auto"
|
|
24
|
-
# Sample Response with ExtendedStatus On
|
|
25
|
-
# Total Accesses: 20643
|
|
26
|
-
# Total kBytes: 36831
|
|
27
|
-
# CPULoad: .0180314
|
|
28
|
-
# Uptime: 43868
|
|
29
|
-
# ReqPerSec: .470571
|
|
30
|
-
# BytesPerSec: 859.737
|
|
31
|
-
# BytesPerReq: 1827.01
|
|
32
|
-
# BusyWorkers: 6
|
|
33
|
-
# IdleWorkers: 94
|
|
34
|
-
# Scoreboard: ___K_____K____________W_
|
|
35
|
-
|
|
36
|
-
@scoreboard_map = {
|
|
37
|
-
'_' => 'waiting',
|
|
38
|
-
'S' => 'starting',
|
|
39
|
-
'R' => 'reading',
|
|
40
|
-
'W' => 'sending',
|
|
41
|
-
'K' => 'keepalive',
|
|
42
|
-
'D' => 'dns',
|
|
43
|
-
'C' => 'closing',
|
|
44
|
-
'L' => 'logging',
|
|
45
|
-
'G' => 'graceful',
|
|
46
|
-
'I' => 'idle',
|
|
47
|
-
'.' => 'open',
|
|
48
|
-
}
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def get_scoreboard_metrics(response)
|
|
52
|
-
results = Hash.new(0)
|
|
53
|
-
|
|
54
|
-
response.slice! 'Scoreboard: '
|
|
55
|
-
response.each_char do |char|
|
|
56
|
-
results[char] += 1
|
|
57
|
-
end
|
|
58
|
-
results.transform_keys { |k| @scoreboard_map[k] }
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def report_metrics(metrics)
|
|
62
|
-
metrics.each do |k, v|
|
|
63
|
-
report(
|
|
64
|
-
service: "httpd #{k}",
|
|
65
|
-
metric: v.to_f,
|
|
66
|
-
state: 'ok',
|
|
67
|
-
tags: ['httpd'],
|
|
68
|
-
)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def connection
|
|
73
|
-
response = nil
|
|
74
|
-
begin
|
|
75
|
-
response = Net::HTTP.get(@uri)
|
|
76
|
-
rescue StandardError => e
|
|
77
|
-
report(
|
|
78
|
-
service: 'httpd health',
|
|
79
|
-
state: 'critical',
|
|
80
|
-
description: "Httpd connection error: #{e.class} - #{e.message}",
|
|
81
|
-
tags: ['httpd'],
|
|
82
|
-
)
|
|
83
|
-
else
|
|
84
|
-
report(
|
|
85
|
-
service: 'httpd health',
|
|
86
|
-
state: 'ok',
|
|
87
|
-
description: 'Httpd connection status ok',
|
|
88
|
-
tags: ['httpd'],
|
|
89
|
-
)
|
|
90
|
-
end
|
|
91
|
-
response
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def tick
|
|
95
|
-
return if (response = connection).nil?
|
|
96
|
-
|
|
97
|
-
response.each_line do |line|
|
|
98
|
-
metrics = {}
|
|
99
|
-
|
|
100
|
-
if line =~ /Scoreboard/
|
|
101
|
-
metrics = get_scoreboard_metrics(line.strip)
|
|
102
|
-
else
|
|
103
|
-
key, value = line.strip.split(':')
|
|
104
|
-
metrics[key.gsub(/\s/, '')] = value
|
|
105
|
-
end
|
|
106
|
-
report_metrics(metrics)
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
6
|
+
require 'riemann/tools/apache_status'
|
|
112
7
|
|
|
113
8
|
Riemann::Tools::ApacheStatus.run
|
data/bin/riemann-bench
CHANGED
|
@@ -3,74 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
# events for testing.
|
|
6
|
+
require 'riemann/tools/bench'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
require 'riemann/client'
|
|
11
|
-
require 'pp'
|
|
12
|
-
|
|
13
|
-
module Riemann
|
|
14
|
-
class Bench
|
|
15
|
-
attr_accessor :client, :hosts, :services, :states
|
|
16
|
-
|
|
17
|
-
def initialize
|
|
18
|
-
@hosts = [nil] + (0...10).map { |i| "host#{i}" }
|
|
19
|
-
@hosts = %w[a b c d e f g h i j]
|
|
20
|
-
@services = %w[test1 test2 test3 foo bar baz xyzzy attack cat treat]
|
|
21
|
-
@states = {}
|
|
22
|
-
@client = Riemann::Client.new(host: (ARGV.first || 'localhost'))
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def evolve(state)
|
|
26
|
-
m = state[:metric] + (rand - 0.5) * 0.1
|
|
27
|
-
m = [[0, m].max, 1].min
|
|
28
|
-
|
|
29
|
-
s = case m
|
|
30
|
-
when 0...0.75
|
|
31
|
-
'ok'
|
|
32
|
-
when 0.75...0.9
|
|
33
|
-
'warning'
|
|
34
|
-
when 0.9..1.0
|
|
35
|
-
'critical'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
metric: m,
|
|
40
|
-
state: s,
|
|
41
|
-
host: state[:host],
|
|
42
|
-
service: state[:service],
|
|
43
|
-
description: "at #{Time.now}",
|
|
44
|
-
}
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def tick
|
|
48
|
-
# pp @states
|
|
49
|
-
hosts.product(services).each do |id|
|
|
50
|
-
client << (states[id] = evolve(states[id]))
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def run
|
|
55
|
-
start
|
|
56
|
-
loop do
|
|
57
|
-
sleep 0.05
|
|
58
|
-
tick
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def start
|
|
63
|
-
hosts.product(services).each do |host, service|
|
|
64
|
-
states[[host, service]] = {
|
|
65
|
-
metric: 0.5,
|
|
66
|
-
state: 'ok',
|
|
67
|
-
description: 'Starting up',
|
|
68
|
-
host: host,
|
|
69
|
-
service: service,
|
|
70
|
-
}
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
Riemann::Bench.new.run
|
|
8
|
+
Riemann::Tools::Bench.new.run
|
data/bin/riemann-cloudant
CHANGED
|
@@ -3,61 +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 Cloudant
|
|
13
|
-
include Riemann::Tools
|
|
14
|
-
require 'net/http'
|
|
15
|
-
require 'json'
|
|
16
|
-
|
|
17
|
-
opt :cloudant_username, 'Cloudant username', type: :string, required: true
|
|
18
|
-
opt :cloudant_password, 'Cloudant pasword', type: :string, required: true
|
|
19
|
-
|
|
20
|
-
def tick
|
|
21
|
-
json.each do |node|
|
|
22
|
-
break if node['svname'] == 'BACKEND' # this is just a sum of all nodes.
|
|
23
|
-
|
|
24
|
-
ns = "cloudant #{node['pxname']}"
|
|
25
|
-
cluster_name = node['tracked'].split('.')[0] # ie: meritage.cloudant.com
|
|
26
|
-
|
|
27
|
-
# report health of each node.
|
|
28
|
-
report(
|
|
29
|
-
service: ns,
|
|
30
|
-
state: (node['status'] == 'UP' ? 'ok' : 'critical'),
|
|
31
|
-
tags: ['cloudant', cluster_name],
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
# report property->metric of each node.
|
|
35
|
-
node.each do |property, metric|
|
|
36
|
-
next if %w[pxname svname status tracked].include?(property)
|
|
37
|
-
|
|
38
|
-
report(
|
|
39
|
-
host: node['tracked'],
|
|
40
|
-
service: "#{ns} #{property}",
|
|
41
|
-
metric: metric.to_f,
|
|
42
|
-
state: (node['status'] == 'UP' ? 'ok' : 'critical'),
|
|
43
|
-
tags: ['cloudant', cluster_name],
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def json
|
|
50
|
-
http = Net::HTTP.new('cloudant.com', 443)
|
|
51
|
-
http.use_ssl = true
|
|
52
|
-
http.start do |h|
|
|
53
|
-
get = Net::HTTP::Get.new('/api/load_balancer')
|
|
54
|
-
get.basic_auth opts[:cloudant_username], opts[:cloudant_password]
|
|
55
|
-
h.request get
|
|
56
|
-
end
|
|
57
|
-
JSON.parse(http.boby)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
6
|
+
require 'riemann/tools/cloudant'
|
|
62
7
|
|
|
63
8
|
Riemann::Tools::Cloudant.run
|
data/bin/riemann-consul
CHANGED
|
@@ -3,111 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require File.expand_path('../lib/riemann/tools', __dir__)
|
|
9
|
-
require 'socket'
|
|
10
|
-
require 'net/http'
|
|
11
|
-
require 'uri'
|
|
12
|
-
require 'json'
|
|
13
|
-
|
|
14
|
-
module Riemann
|
|
15
|
-
module Tools
|
|
16
|
-
class ConsulHealth
|
|
17
|
-
include Riemann::Tools
|
|
18
|
-
|
|
19
|
-
opt :consul_host, 'Consul API Host (default to localhost)', default: 'localhost'
|
|
20
|
-
opt :consul_port, 'Consul API Host (default to 8500)', default: '8500'
|
|
21
|
-
opt :prefix, 'prefix to use for all service names when reporting', default: 'consul '
|
|
22
|
-
opt :minimum_services_per_node, 'minimum services per node (default: 0)', default: 0
|
|
23
|
-
|
|
24
|
-
def initialize
|
|
25
|
-
@hostname = opts[:consul_host]
|
|
26
|
-
@prefix = opts[:prefix]
|
|
27
|
-
@minimum_services_per_node = opts[:minimum_services_per_node]
|
|
28
|
-
@underlying_ip = IPSocket.getaddress(@hostname)
|
|
29
|
-
@consul_leader_url = URI.parse("http://#{opts[:consul_host]}:#{opts[:consul_port]}/v1/status/leader")
|
|
30
|
-
@consul_services_url = URI.parse("http://#{opts[:consul_host]}:#{opts[:consul_port]}/v1/catalog/services")
|
|
31
|
-
@consul_nodes_url = URI.parse("http://#{opts[:consul_host]}:#{opts[:consul_port]}/v1/catalog/nodes")
|
|
32
|
-
@consul_health_url_prefix = "http://#{opts[:consul_host]}:#{opts[:consul_port]}/v1/health/service/"
|
|
33
|
-
|
|
34
|
-
@last_services_read = {}
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def alert(hostname, service, state, metric, description)
|
|
38
|
-
opts = {
|
|
39
|
-
host: hostname,
|
|
40
|
-
service: service.to_s,
|
|
41
|
-
state: state.to_s,
|
|
42
|
-
metric: metric,
|
|
43
|
-
description: description,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
report(opts)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def get(url)
|
|
50
|
-
Net::HTTP.get_response(url).body
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def tick
|
|
54
|
-
leader = JSON.parse(get(@consul_leader_url))
|
|
55
|
-
leader_hostname = URI.parse("http://#{leader}").hostname
|
|
56
|
-
|
|
57
|
-
return unless leader_hostname == @underlying_ip
|
|
58
|
-
|
|
59
|
-
nodes = JSON.parse(get(@consul_nodes_url))
|
|
60
|
-
services = JSON.parse(get(@consul_services_url))
|
|
61
|
-
services_by_nodes = {}
|
|
62
|
-
|
|
63
|
-
nodes.each do |node|
|
|
64
|
-
node_name = node['Node']
|
|
65
|
-
services_by_nodes[node_name] = 0
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# For every service
|
|
69
|
-
services.each do |service|
|
|
70
|
-
service_name = service[0]
|
|
71
|
-
health_url = URI.parse(@consul_health_url_prefix + service_name)
|
|
72
|
-
health_nodes = JSON.parse(get(health_url))
|
|
73
|
-
|
|
74
|
-
total_count = 0
|
|
75
|
-
ok_count = 0
|
|
76
|
-
|
|
77
|
-
health_nodes.each do |node|
|
|
78
|
-
hostname = node['Node']['Node']
|
|
79
|
-
ok = node['Checks'].all? { |check| check['Status'] == 'passing' }
|
|
80
|
-
alert(hostname, "#{@prefix}#{service_name}", ok ? :ok : :critical, ok ? 1 : 0, JSON.generate(node))
|
|
81
|
-
total_count += 1
|
|
82
|
-
ok_count += ok ? 1 : 0
|
|
83
|
-
|
|
84
|
-
last_services_by_nodes = services_by_nodes[hostname].to_i
|
|
85
|
-
services_by_nodes[hostname] = last_services_by_nodes + 1
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
unless @last_services_read[service_name].nil?
|
|
89
|
-
last_ok = @last_services_read[service_name]
|
|
90
|
-
if last_ok != ok_count
|
|
91
|
-
alert(
|
|
92
|
-
'total', "#{@prefix}#{service_name}-count", ok_count >= last_ok ? :ok : :critical, ok_count,
|
|
93
|
-
"Number of passing #{service_name} is: #{ok_count}/#{total_count}, Last time it was: #{last_ok}",
|
|
94
|
-
)
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
@last_services_read[service_name] = ok_count
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# For every node
|
|
102
|
-
services_by_nodes.each do |node, count|
|
|
103
|
-
alert(
|
|
104
|
-
node, "#{@prefix}total-services", count >= @minimum_services_per_node ? :ok : :critical, count,
|
|
105
|
-
"#{count} services in the specified node",
|
|
106
|
-
)
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
6
|
+
require 'riemann/tools/consul_health'
|
|
112
7
|
|
|
113
8
|
Riemann::Tools::ConsulHealth.run
|
data/bin/riemann-dir-files-count
CHANGED
|
@@ -3,60 +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 DirFilesCount
|
|
13
|
-
include Riemann::Tools
|
|
14
|
-
|
|
15
|
-
opt :directory, '', default: '/var/log'
|
|
16
|
-
opt :service_prefix, 'The first part of the service name, before the directory path', default: 'dir-files-count'
|
|
17
|
-
opt :warning, 'Dir files number warning threshold', type: Integer
|
|
18
|
-
opt :critical, 'Dir files number critical threshold', type: Integer
|
|
19
|
-
opt :alert_on_missing, 'Send a critical metric if the directory is missing?', default: true
|
|
20
|
-
|
|
21
|
-
def initialize
|
|
22
|
-
@dir = opts.fetch(:directory)
|
|
23
|
-
@service_prefix = opts.fetch(:service_prefix)
|
|
24
|
-
@warning = opts.fetch(:warning, nil)
|
|
25
|
-
@critical = opts.fetch(:critical, nil)
|
|
26
|
-
@alert_on_missing = opts.fetch(:alert_on_missing)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def tick
|
|
30
|
-
if Dir.exist?(@dir)
|
|
31
|
-
metric = Dir.entries(@dir).size - 2
|
|
32
|
-
report(
|
|
33
|
-
service: "#{@service_prefix} #{@dir}",
|
|
34
|
-
metric: metric,
|
|
35
|
-
state: state(metric),
|
|
36
|
-
tags: ['dir_files_count'],
|
|
37
|
-
)
|
|
38
|
-
elsif @alert_on_missing
|
|
39
|
-
report(
|
|
40
|
-
service: "#{@service_prefix} #{@dir} missing",
|
|
41
|
-
description: "#{@service_prefix} #{@dir} does not exist",
|
|
42
|
-
metric: metric,
|
|
43
|
-
state: 'critical',
|
|
44
|
-
tags: ['dir_files_count'],
|
|
45
|
-
)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def state(metric)
|
|
50
|
-
if @critical && metric > @critical
|
|
51
|
-
'critical'
|
|
52
|
-
elsif @warning && metric > @warning
|
|
53
|
-
'warning'
|
|
54
|
-
else
|
|
55
|
-
'ok'
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
6
|
+
require 'riemann/tools/dir_files_count'
|
|
61
7
|
|
|
62
8
|
Riemann::Tools::DirFilesCount.run
|
data/bin/riemann-dir-space
CHANGED
|
@@ -3,60 +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 DirSpace
|
|
13
|
-
include Riemann::Tools
|
|
14
|
-
|
|
15
|
-
opt :directory, '', default: '/var/log'
|
|
16
|
-
opt :service_prefix, 'The first part of the service name, before the directory path', default: 'dir-space'
|
|
17
|
-
opt :warning, 'Dir space warning threshold (in bytes)', type: Integer
|
|
18
|
-
opt :critical, 'Dir space critical threshold (in bytes)', type: Integer
|
|
19
|
-
opt :alert_on_missing, 'Send a critical metric if the directory is missing?', default: true
|
|
20
|
-
|
|
21
|
-
def initialize
|
|
22
|
-
@dir = opts.fetch(:directory)
|
|
23
|
-
@service_prefix = opts.fetch(:service_prefix)
|
|
24
|
-
@warning = opts.fetch(:warning, nil)
|
|
25
|
-
@critical = opts.fetch(:critical, nil)
|
|
26
|
-
@alert_on_missing = opts.fetch(:alert_on_missing)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def tick
|
|
30
|
-
if Dir.exist?(@dir)
|
|
31
|
-
metric = `du '#{@dir}'`.lines.to_a.last.split("\t")[0].to_i
|
|
32
|
-
report(
|
|
33
|
-
service: "#{@service_prefix} #{@dir}",
|
|
34
|
-
metric: metric,
|
|
35
|
-
state: state(metric),
|
|
36
|
-
tags: ['dir_space'],
|
|
37
|
-
)
|
|
38
|
-
elsif @alert_on_missing
|
|
39
|
-
report(
|
|
40
|
-
service: "#{@service_prefix} #{@dir} missing",
|
|
41
|
-
description: "#{@service_prefix} #{@dir} does not exist",
|
|
42
|
-
metric: metric,
|
|
43
|
-
state: 'critical',
|
|
44
|
-
tags: ['dir_space'],
|
|
45
|
-
)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def state(metric)
|
|
50
|
-
if @critical && metric > @critical
|
|
51
|
-
'critical'
|
|
52
|
-
elsif @warning && metric > @warning
|
|
53
|
-
'warning'
|
|
54
|
-
else
|
|
55
|
-
'ok'
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
6
|
+
require 'riemann/tools/dir_space'
|
|
61
7
|
|
|
62
8
|
Riemann::Tools::DirSpace.run
|