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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +8 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +25 -2
  7. data/Rakefile +10 -3
  8. data/bin/riemann-apache-status +1 -106
  9. data/bin/riemann-bench +2 -70
  10. data/bin/riemann-cloudant +1 -56
  11. data/bin/riemann-consul +1 -106
  12. data/bin/riemann-dir-files-count +1 -55
  13. data/bin/riemann-dir-space +1 -55
  14. data/bin/riemann-diskstats +1 -92
  15. data/bin/riemann-fd +2 -81
  16. data/bin/riemann-freeswitch +2 -119
  17. data/bin/riemann-haproxy +1 -58
  18. data/bin/riemann-health +0 -2
  19. data/bin/riemann-kvminstance +2 -22
  20. data/bin/riemann-memcached +1 -37
  21. data/bin/riemann-net +0 -2
  22. data/bin/riemann-nginx-status +1 -85
  23. data/bin/riemann-ntp +0 -2
  24. data/bin/riemann-portcheck +1 -44
  25. data/bin/riemann-proc +1 -108
  26. data/bin/riemann-varnish +1 -54
  27. data/bin/riemann-wrapper +75 -0
  28. data/bin/riemann-zookeeper +1 -39
  29. data/lib/riemann/tools/apache_status.rb +107 -0
  30. data/lib/riemann/tools/bench.rb +72 -0
  31. data/lib/riemann/tools/cloudant.rb +57 -0
  32. data/lib/riemann/tools/consul_health.rb +107 -0
  33. data/lib/riemann/tools/dir_files_count.rb +56 -0
  34. data/lib/riemann/tools/dir_space.rb +56 -0
  35. data/lib/riemann/tools/diskstats.rb +94 -0
  36. data/lib/riemann/tools/fd.rb +81 -0
  37. data/lib/riemann/tools/freeswitch.rb +119 -0
  38. data/lib/riemann/tools/haproxy.rb +59 -0
  39. data/lib/riemann/tools/health.rb +150 -19
  40. data/lib/riemann/tools/kvm.rb +23 -0
  41. data/lib/riemann/tools/memcached.rb +38 -0
  42. data/lib/riemann/tools/net.rb +2 -1
  43. data/lib/riemann/tools/nginx_status.rb +86 -0
  44. data/lib/riemann/tools/ntp.rb +1 -0
  45. data/lib/riemann/tools/portcheck.rb +45 -0
  46. data/lib/riemann/tools/proc.rb +109 -0
  47. data/lib/riemann/tools/riemann_client_wrapper.rb +43 -0
  48. data/lib/riemann/tools/uptime_parser.tab.rb +323 -0
  49. data/lib/riemann/tools/varnish.rb +55 -0
  50. data/lib/riemann/tools/version.rb +1 -1
  51. data/lib/riemann/tools/zookeeper.rb +40 -0
  52. data/lib/riemann/tools.rb +2 -20
  53. data/riemann-tools.gemspec +4 -1
  54. data/tools/riemann-aws/Rakefile +6 -9
  55. data/tools/riemann-aws/bin/riemann-aws-billing +2 -87
  56. data/tools/riemann-aws/bin/riemann-aws-rds-status +2 -62
  57. data/tools/riemann-aws/bin/riemann-aws-sqs-status +2 -44
  58. data/tools/riemann-aws/bin/riemann-aws-status +2 -77
  59. data/tools/riemann-aws/bin/riemann-elb-metrics +2 -162
  60. data/tools/riemann-aws/bin/riemann-s3-list +2 -81
  61. data/tools/riemann-aws/bin/riemann-s3-status +2 -96
  62. data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +87 -0
  63. data/tools/riemann-aws/lib/riemann/tools/aws/elb_metrics.rb +163 -0
  64. data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +63 -0
  65. data/tools/riemann-aws/lib/riemann/tools/aws/s3_list.rb +82 -0
  66. data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +97 -0
  67. data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +45 -0
  68. data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +74 -0
  69. data/tools/riemann-chronos/Rakefile +6 -9
  70. data/tools/riemann-chronos/bin/riemann-chronos +1 -154
  71. data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +157 -0
  72. data/tools/riemann-docker/Rakefile +5 -8
  73. data/tools/riemann-docker/bin/riemann-docker +2 -200
  74. data/tools/riemann-docker/lib/riemann/tools/docker.rb +200 -0
  75. data/tools/riemann-elasticsearch/Rakefile +6 -9
  76. data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +1 -167
  77. data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +170 -0
  78. data/tools/riemann-marathon/Rakefile +6 -9
  79. data/tools/riemann-marathon/bin/riemann-marathon +1 -156
  80. data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +159 -0
  81. data/tools/riemann-mesos/Rakefile +6 -9
  82. data/tools/riemann-mesos/bin/riemann-mesos +1 -139
  83. data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +142 -0
  84. data/tools/riemann-munin/Rakefile +5 -8
  85. data/tools/riemann-munin/bin/riemann-munin +1 -36
  86. data/tools/riemann-munin/lib/riemann/tools/munin.rb +37 -0
  87. data/tools/riemann-rabbitmq/Rakefile +6 -9
  88. data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +1 -266
  89. data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +269 -0
  90. data/tools/riemann-riak/Rakefile +5 -8
  91. data/tools/riemann-riak/bin/riemann-riak +1 -316
  92. data/tools/riemann-riak/bin/riemann-riak-keys +0 -1
  93. data/tools/riemann-riak/bin/riemann-riak-ring +0 -1
  94. data/tools/riemann-riak/lib/riemann/tools/riak.rb +317 -0
  95. metadata +57 -10
  96. data/.travis.yml +0 -31
  97. data/tools/riemann-riak/riak_status/key_count.erl +0 -13
  98. data/tools/riemann-riak/riak_status/riak_status.rb +0 -152
  99. 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: 5eab5c1ce9c48820a1d492d8d97d0898078880306553dc89cc9d68b1a9e01d03
4
- data.tar.gz: 60b8fbc757e7775df69ea830013d81afc6521343a0abce8a516a176ef795a2bb
3
+ metadata.gz: fa8ed5841e8d5c02ee08180af284269ca1382e174a2dfd98b28de23227a44f61
4
+ data.tar.gz: 3ec31579be24a493017091aaa928b6cbd091c2d578a7d577d868ac2857e7be3d
5
5
  SHA512:
6
- metadata.gz: efc7d885bc02343f17757f52d6f7c7782691a3674180bb564041eda6d5070d2112d55261a6de2d559c3554e853c4384ade03619062e49ea091bd07dbb5ad1ec6
7
- data.tar.gz: a0bd87531c1a4f1fbeee5acd3777087a67e6617e516d213989a9675a75c0d570397737dbf3c8e7a22f479b1ce0d242ac354003b9571e2fe9ac3f34ab196062c9
6
+ metadata.gz: a5554c62f5ce95494f5ed677ccd6933224121c9d227bc9318ec54bed380e0635f1140fbfc5cf8cd3e2ecc919fc267c12f8fb8c47da58345925c69c6d19c82a51
7
+ data.tar.gz: a1e3a370c5a325eb6acd59c1ad23fb3efcde20f8ff467d75a84c1e52e1f7cd2cd3102d5045bb11bfd43a43f12b01c0823c2b08f6fa75fd1e33ae50818ffa0e02
@@ -38,5 +38,7 @@ jobs:
38
38
  with:
39
39
  ruby-version: ${{ matrix.ruby-version }}
40
40
  bundler-cache: true
41
+ - name: Build the parser
42
+ run: bundle exec rake gen_parser
41
43
  - name: Run the test suite
42
44
  run: bundle exec rspec
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
+ Gemfile.lock
1
2
  pkg/
2
3
  ._*
3
4
  *~
4
5
  .DS_Store
5
6
  .*.swp
6
7
  *.log
8
+ lib/riemann/tools/uptime_parser.tab.rb
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
- ## [1.1.1](https://github.com/riemann/riemann-tools/tree/1.1.1) (2022-07-02)
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.0...1.1.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
@@ -3,111 +3,6 @@
3
3
 
4
4
  Process.setproctitle($PROGRAM_NAME)
5
5
 
6
- # Collects Apache metrics and submits them to Riemann
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
- # Connects to a server (first arg) and populates it with a constant stream of
7
- # events for testing.
6
+ require 'riemann/tools/bench'
8
7
 
9
- require 'rubygems'
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
- # Gathers load balancer statistics from Cloudant.com (shared cluster) and submits them to Riemann.
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
- # Reports service and node status to riemann
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
@@ -3,60 +3,6 @@
3
3
 
4
4
  Process.setproctitle($PROGRAM_NAME)
5
5
 
6
- # Gets the number of files present on a directory and submits it to riemann
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
@@ -3,60 +3,6 @@
3
3
 
4
4
  Process.setproctitle($PROGRAM_NAME)
5
5
 
6
- # Gathers the space used by a directory and submits it to riemann
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