riemann-tools 1.10.0 → 1.11.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 +7 -6
- data/.gitignore +1 -0
- data/.rubocop.yml +18 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile +22 -0
- data/Rakefile +1 -1
- data/bin/riemann-hwmon +8 -0
- data/bin/riemann-tls-check +8 -0
- data/lib/riemann/tools/apache_status.rb +2 -0
- data/lib/riemann/tools/bench.rb +4 -2
- data/lib/riemann/tools/consul_health.rb +2 -0
- data/lib/riemann/tools/dir_files_count.rb +2 -0
- data/lib/riemann/tools/dir_space.rb +2 -0
- data/lib/riemann/tools/diskstats.rb +6 -4
- data/lib/riemann/tools/fd.rb +2 -0
- data/lib/riemann/tools/freeswitch.rb +2 -0
- data/lib/riemann/tools/haproxy.rb +2 -0
- data/lib/riemann/tools/health.rb +79 -11
- data/lib/riemann/tools/http_check.rb +56 -17
- data/lib/riemann/tools/hwmon.rb +111 -0
- data/lib/riemann/tools/mdstat_parser.tab.rb +4 -2
- data/lib/riemann/tools/net.rb +3 -7
- data/lib/riemann/tools/nginx_status.rb +8 -4
- data/lib/riemann/tools/ntp.rb +2 -0
- data/lib/riemann/tools/portcheck.rb +2 -0
- data/lib/riemann/tools/proc.rb +2 -0
- data/lib/riemann/tools/tls_check.rb +604 -0
- data/lib/riemann/tools/utils.rb +39 -0
- data/lib/riemann/tools/varnish.rb +2 -0
- data/lib/riemann/tools/version.rb +1 -1
- data/lib/riemann/tools.rb +26 -9
- data/riemann-tools.gemspec +2 -11
- data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +3 -1
- data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +2 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +1 -1
- data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +2 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +11 -9
- data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +2 -0
- data/tools/riemann-docker/lib/riemann/tools/docker.rb +5 -5
- data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +2 -0
- data/tools/riemann-munin/lib/riemann/tools/munin.rb +2 -0
- data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +7 -7
- data/tools/riemann-riak/lib/riemann/tools/riak.rb +4 -2
- metadata +10 -129
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
# See https://www.kernel.org/doc/html/latest/hwmon/index.html
|
6
|
+
module Riemann
|
7
|
+
module Tools
|
8
|
+
class Hwmon
|
9
|
+
include Riemann::Tools
|
10
|
+
|
11
|
+
class Device
|
12
|
+
attr_reader :hwmon, :type, :number, :crit, :lcrit, :service
|
13
|
+
|
14
|
+
def initialize(hwmon, type, number)
|
15
|
+
@hwmon = hwmon
|
16
|
+
@type = type
|
17
|
+
@number = number
|
18
|
+
|
19
|
+
@crit = scale(read_hwmon_i('crit'))
|
20
|
+
@lcrit = scale(read_hwmon_i('lcrit'))
|
21
|
+
@service = ['hwmon', read_hwmon_file('name'), read_hwmon_s('label')].compact.join(' ')
|
22
|
+
end
|
23
|
+
|
24
|
+
def input
|
25
|
+
read_hwmon_i('input')
|
26
|
+
end
|
27
|
+
|
28
|
+
def report
|
29
|
+
value = scale(input)
|
30
|
+
|
31
|
+
state = :ok
|
32
|
+
state = :critical if crit && value >= crit
|
33
|
+
state = :critical if lcrit && value <= lcrit
|
34
|
+
{
|
35
|
+
service: service,
|
36
|
+
state: state,
|
37
|
+
metric: value,
|
38
|
+
description: fromat_input(value),
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def scale(value)
|
45
|
+
return nil if value.nil?
|
46
|
+
|
47
|
+
case type
|
48
|
+
when :fan then value.to_i # rpm
|
49
|
+
when :in, :temp, :curr then value.to_f / 1000 # mV, m°C, mA
|
50
|
+
when :humidity then value.to_f / 100 # %H
|
51
|
+
when :power, :energy then value.to_f / 1_000_000 # uW, uJ
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def fromat_input(value)
|
56
|
+
case type
|
57
|
+
when :in then format('%<value>.3f V', { value: value })
|
58
|
+
when :fan then "#{value} RPM"
|
59
|
+
when :temp then format('%<value>.3f °C', { value: value })
|
60
|
+
when :curr then format('%<value>.3f A', { value: value })
|
61
|
+
when :power then format('%<value>.3f W', { value: value })
|
62
|
+
when :energy then format('%<value>.3f J', { value: value })
|
63
|
+
when :humidity then format('%<value>d %H', { value: (value * 100).to_i })
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def read_hwmon_i(file)
|
68
|
+
s = read_hwmon_s(file)
|
69
|
+
return nil if s.nil?
|
70
|
+
|
71
|
+
s.to_i
|
72
|
+
end
|
73
|
+
|
74
|
+
def read_hwmon_s(file)
|
75
|
+
read_hwmon_file("#{type}#{number}_#{file}")
|
76
|
+
end
|
77
|
+
|
78
|
+
def read_hwmon_file(file)
|
79
|
+
File.read("/sys/class/hwmon/hwmon#{hwmon}/#{file}").chomp
|
80
|
+
rescue Errno::ENOENT
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
attr_reader :devices
|
86
|
+
|
87
|
+
def initialize
|
88
|
+
super
|
89
|
+
|
90
|
+
@devices = poll_devices
|
91
|
+
end
|
92
|
+
|
93
|
+
def poll_devices
|
94
|
+
res = []
|
95
|
+
|
96
|
+
Dir['/sys/class/hwmon/hwmon[0-9]*/{in,fan,temp,curr,power,energy,humidity}[0-9]*_input'].each do |filename|
|
97
|
+
m = filename.match(%r{/sys/class/hwmon/hwmon(\d+)/([[:alpha:]]+)(\d+)_input})
|
98
|
+
res << Device.new(m[1].to_i, m[2].to_sym, m[3].to_i)
|
99
|
+
end
|
100
|
+
|
101
|
+
res
|
102
|
+
end
|
103
|
+
|
104
|
+
def tick
|
105
|
+
devices.each do |device|
|
106
|
+
report(device.report)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.
|
4
|
-
# from Racc grammar file "".
|
3
|
+
# This file is automatically generated by Racc 1.7.3
|
4
|
+
# from Racc grammar file "mdstat_parser.y".
|
5
5
|
#
|
6
6
|
|
7
7
|
require 'racc/parser.rb'
|
@@ -255,6 +255,7 @@ Racc_arg = [
|
|
255
255
|
racc_shift_n,
|
256
256
|
racc_reduce_n,
|
257
257
|
racc_use_result_var ]
|
258
|
+
Ractor.make_shareable(Racc_arg) if defined?(Ractor)
|
258
259
|
|
259
260
|
Racc_token_to_s_table = [
|
260
261
|
"$end",
|
@@ -312,6 +313,7 @@ Racc_token_to_s_table = [
|
|
312
313
|
"bitmap",
|
313
314
|
"progress_action",
|
314
315
|
"identifiers" ]
|
316
|
+
Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
|
315
317
|
|
316
318
|
Racc_debug_parser = false
|
317
319
|
|
data/lib/riemann/tools/net.rb
CHANGED
@@ -12,6 +12,8 @@ module Riemann
|
|
12
12
|
opt :ignore_interfaces, 'Interfaces to ignore', type: :strings, default: ['\Alo\d*\z']
|
13
13
|
|
14
14
|
def initialize
|
15
|
+
super
|
16
|
+
|
15
17
|
@old_state = nil
|
16
18
|
@interfaces = if opts[:interfaces]
|
17
19
|
opts[:interfaces].reject(&:empty?).map(&:dup)
|
@@ -118,13 +120,7 @@ module Riemann
|
|
118
120
|
|
119
121
|
delta = metric - @old_state[service]
|
120
122
|
svc_state = case service
|
121
|
-
when /drop$/
|
122
|
-
if delta.positive?
|
123
|
-
'warning'
|
124
|
-
else
|
125
|
-
'ok'
|
126
|
-
end
|
127
|
-
when /errs$/
|
123
|
+
when /drop$/, /errs$/
|
128
124
|
if delta.positive?
|
129
125
|
'warning'
|
130
126
|
else
|
@@ -26,6 +26,8 @@ module Riemann
|
|
26
26
|
opt :user_agent, 'User-Agent header for HTTP requests', short: :none, default: "#{File.basename($PROGRAM_NAME)}/#{Riemann::Tools::VERSION} (+https://github.com/riemann/riemann-tools)"
|
27
27
|
|
28
28
|
def initialize
|
29
|
+
super
|
30
|
+
|
29
31
|
@uri = URI.parse(opts[:uri])
|
30
32
|
|
31
33
|
# sample response:
|
@@ -39,13 +41,13 @@ module Riemann
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def state(key, value)
|
42
|
-
if opts.key? "#{key}_critical"
|
43
|
-
critical_threshold = opts["#{key}_critical"
|
44
|
+
if opts.key? :"#{key}_critical"
|
45
|
+
critical_threshold = opts[:"#{key}_critical"]
|
44
46
|
return 'critical' if critical_threshold.positive? && (value >= critical_threshold)
|
45
47
|
end
|
46
48
|
|
47
|
-
if opts.key? "#{key}_warning"
|
48
|
-
warning_threshold = opts["#{key}_warning"
|
49
|
+
if opts.key? :"#{key}_warning"
|
50
|
+
warning_threshold = opts[:"#{key}_warning"]
|
49
51
|
return 'warning' if warning_threshold.positive? && (value >= warning_threshold)
|
50
52
|
end
|
51
53
|
|
@@ -75,6 +77,8 @@ module Riemann
|
|
75
77
|
values = @re.match(response).to_a[1, 7].map(&:to_i)
|
76
78
|
|
77
79
|
@keys.zip(values).each do |key, value|
|
80
|
+
next unless opts[:checks].include?(key)
|
81
|
+
|
78
82
|
report({
|
79
83
|
service: "nginx #{key}",
|
80
84
|
metric: value,
|
data/lib/riemann/tools/ntp.rb
CHANGED
data/lib/riemann/tools/proc.rb
CHANGED
@@ -13,6 +13,8 @@ module Riemann
|
|
13
13
|
opt :proc_max_critical, 'running process count maximum', default: 65_536
|
14
14
|
|
15
15
|
def initialize
|
16
|
+
super
|
17
|
+
|
16
18
|
@limits = { critical: { min: opts[:proc_min_critical], max: opts[:proc_max_critical] } }
|
17
19
|
|
18
20
|
abort 'FATAL: specify a process regular expression, see --help for usage' unless opts[:proc_regex]
|