riemann-tools 1.1.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
# Gathers memcached STATS and submits them to Riemann.
|
6
|
+
module Riemann
|
7
|
+
module Tools
|
8
|
+
class Memcached
|
9
|
+
include Riemann::Tools
|
10
|
+
require 'socket'
|
11
|
+
|
12
|
+
opt :memcached_host, 'Memcached hostname', default: 'localhost'
|
13
|
+
opt :memcached_port, 'Memcached port', default: 11_211
|
14
|
+
|
15
|
+
def tick
|
16
|
+
sock = TCPSocket.new(opts[:memcached_host], opts[:memcached_port])
|
17
|
+
sock.print("stats\r\n")
|
18
|
+
sock.flush
|
19
|
+
stats = sock.gets
|
20
|
+
|
21
|
+
loop do
|
22
|
+
stats = sock.gets
|
23
|
+
break if stats.strip == 'END'
|
24
|
+
|
25
|
+
m = stats.match(/STAT (\w+) (\S+)/)
|
26
|
+
report(
|
27
|
+
host: opts[:memcached_host].dup,
|
28
|
+
service: "memcached #{m[1]}",
|
29
|
+
metric: m[2].to_f,
|
30
|
+
state: 'ok',
|
31
|
+
tags: ['memcached'],
|
32
|
+
)
|
33
|
+
end
|
34
|
+
sock.close
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/riemann/tools/net.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'riemann/tools'
|
4
4
|
|
5
|
+
# Gathers network interface statistics and submits them to Riemann.
|
5
6
|
module Riemann
|
6
7
|
module Tools
|
7
8
|
class Net
|
@@ -42,7 +43,7 @@ module Riemann
|
|
42
43
|
'tx bytes',
|
43
44
|
'tx packets',
|
44
45
|
'tx errs',
|
45
|
-
'tx
|
46
|
+
'tx drop',
|
46
47
|
'tx fifo',
|
47
48
|
'tx colls',
|
48
49
|
'tx carrier',
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
# Gathers nginx status stub statistics and submits them to Riemann.
|
6
|
+
# See http://wiki.nginx.org/HttpStubStatusModule for configuring Nginx appropriately
|
7
|
+
module Riemann
|
8
|
+
module Tools
|
9
|
+
class NginxStatus
|
10
|
+
include Riemann::Tools
|
11
|
+
require 'net/http'
|
12
|
+
require 'uri'
|
13
|
+
|
14
|
+
opt :uri, 'Nginx Stub Status URI', default: 'http://localhost:8080/nginx_status'
|
15
|
+
opt :checks, 'Which metrics to report.', type: :strings,
|
16
|
+
default: %w[active accepted handled requests reading writing waiting]
|
17
|
+
opt :active_warning, 'Active connections warning threshold', default: 0
|
18
|
+
opt :active_critical, 'Active connections critical threshold', default: 0
|
19
|
+
opt :reading_warning, 'Reading connections warning threshold', default: 0
|
20
|
+
opt :reading_critical, 'Reading connections critical threshold', default: 0
|
21
|
+
opt :writing_warning, 'Writing connections warning threshold', default: 0
|
22
|
+
opt :writing_critical, 'Writing connections critical threshold', default: 0
|
23
|
+
opt :waiting_warning, 'Waiting connections warning threshold', default: 0
|
24
|
+
opt :waiting_critical, 'Waiting connections critical threshold', default: 0
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@uri = URI.parse(opts[:uri])
|
28
|
+
|
29
|
+
# sample response:
|
30
|
+
#
|
31
|
+
# Active connections: 1
|
32
|
+
# server accepts handled requests
|
33
|
+
# 39 39 39
|
34
|
+
# Reading: 0 Writing: 1 Waiting: 0
|
35
|
+
@keys = %w[active accepted handled requests reading writing waiting]
|
36
|
+
@re = /Active connections: (\d+) \n.+\n (\d+) (\d+) (\d+) \nReading: (\d+) Writing: (\d+) Waiting: (\d+)/m
|
37
|
+
end
|
38
|
+
|
39
|
+
def state(key, value)
|
40
|
+
if opts.key? "#{key}_critical".to_sym
|
41
|
+
critical_threshold = opts["#{key}_critical".to_sym]
|
42
|
+
return 'critical' if critical_threshold.positive? && (value >= critical_threshold)
|
43
|
+
end
|
44
|
+
|
45
|
+
if opts.key? "#{key}_warning".to_sym
|
46
|
+
warning_threshold = opts["#{key}_warning".to_sym]
|
47
|
+
return 'warning' if warning_threshold.positive? && (value >= warning_threshold)
|
48
|
+
end
|
49
|
+
|
50
|
+
'ok'
|
51
|
+
end
|
52
|
+
|
53
|
+
def tick
|
54
|
+
response = nil
|
55
|
+
begin
|
56
|
+
response = ::Net::HTTP.get(@uri)
|
57
|
+
rescue StandardError => e
|
58
|
+
report(
|
59
|
+
service: 'nginx health',
|
60
|
+
state: 'critical',
|
61
|
+
description: "Connection error: #{e.class} - #{e.message}",
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
return if response.nil?
|
66
|
+
|
67
|
+
report(
|
68
|
+
service: 'nginx health',
|
69
|
+
state: 'ok',
|
70
|
+
description: 'Nginx status connection ok',
|
71
|
+
)
|
72
|
+
|
73
|
+
values = @re.match(response).to_a[1, 7].map(&:to_i)
|
74
|
+
|
75
|
+
@keys.zip(values).each do |key, value|
|
76
|
+
report({
|
77
|
+
service: "nginx #{key}",
|
78
|
+
metric: value,
|
79
|
+
state: state(key, value),
|
80
|
+
tags: ['nginx'],
|
81
|
+
})
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/riemann/tools/ntp.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
# Checks for open tcp ports.
|
6
|
+
# (c) Max Voit 2017
|
7
|
+
module Riemann
|
8
|
+
module Tools
|
9
|
+
class Portcheck
|
10
|
+
include Riemann::Tools
|
11
|
+
require 'socket'
|
12
|
+
|
13
|
+
opt :hostname, 'Host, defaults to localhost', default: `hostname`.chomp
|
14
|
+
opt :ports, "List of ports to check, e.g. '-r 80 443'", type: :ints
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@hostname = opts.fetch(:hostname)
|
18
|
+
@ports = opts.fetch(:ports)
|
19
|
+
end
|
20
|
+
|
21
|
+
def tick
|
22
|
+
@ports.each do |thisport|
|
23
|
+
# try opening tcp connection with 5s timeout;
|
24
|
+
# if this fails, the port is considered closed
|
25
|
+
portopen = begin
|
26
|
+
Socket.tcp(@hostname, thisport, connect_timeout: 5) { true }
|
27
|
+
rescue StandardError
|
28
|
+
false
|
29
|
+
end
|
30
|
+
state = if portopen
|
31
|
+
'ok'
|
32
|
+
else
|
33
|
+
'critical'
|
34
|
+
end
|
35
|
+
report(
|
36
|
+
host: @hostname.to_s,
|
37
|
+
service: "port #{thisport}",
|
38
|
+
state: state.to_s,
|
39
|
+
tags: ['portcheck'],
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
# Reports running process count to riemann.
|
6
|
+
module Riemann
|
7
|
+
module Tools
|
8
|
+
class Proc
|
9
|
+
include Riemann::Tools
|
10
|
+
|
11
|
+
opt :proc_regex, 'regular expression that matches the process to be monitored', type: :string, default: '.*'
|
12
|
+
opt :proc_min_critical, 'running process count minimum', default: 0
|
13
|
+
opt :proc_max_critical, 'running process count maximum', default: 65_536
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@limits = { critical: { min: opts[:proc_min_critical], max: opts[:proc_max_critical] } }
|
17
|
+
|
18
|
+
abort 'FATAL: specify a process regular expression, see --help for usage' unless opts[:proc_regex]
|
19
|
+
|
20
|
+
ostype = `uname -s`.chomp.downcase
|
21
|
+
puts "WARNING: OS '#{ostype}' not explicitly supported. Falling back to Linux" unless ostype == 'linux'
|
22
|
+
@check = method :linux_proc
|
23
|
+
end
|
24
|
+
|
25
|
+
def alert(service, state, metric, description)
|
26
|
+
report(
|
27
|
+
service: service.to_s,
|
28
|
+
state: state.to_s,
|
29
|
+
metric: metric.to_f,
|
30
|
+
description: description,
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def linux_proc
|
35
|
+
process = opts[:proc_regex]
|
36
|
+
found = `ps axo pid=,rss=,vsize=,state=,cputime=,lstart=,command= | grep '#{process}' | grep -v grep | grep -v riemann-proc`
|
37
|
+
running = found.count("\n")
|
38
|
+
if (running > @limits[:critical][:max]) || (running < @limits[:critical][:min])
|
39
|
+
alert "proc count/#{process}", :critical, running, "process #{process} is running #{running} instances.\n"
|
40
|
+
else
|
41
|
+
alert "proc count/#{process}", :ok, running, "process #{process} is running #{running} instances.\n"
|
42
|
+
end
|
43
|
+
# Iterate on all the lines and create an entry for the following metrics:
|
44
|
+
#
|
45
|
+
# process/<pid>-<start-time>/rss
|
46
|
+
# process/<pid>-<start-time>/vsize
|
47
|
+
# process/<pid>-<start-time>/running
|
48
|
+
# process/<pid>-<start-time>/cputime
|
49
|
+
#
|
50
|
+
# description should contain the command itself.
|
51
|
+
# value should be either process RSS, VSIZE, or 1 if running
|
52
|
+
# state is always unknown for the moment
|
53
|
+
#
|
54
|
+
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]+) +(.*)/
|
55
|
+
found.each_line do |line|
|
56
|
+
m = ps_regex.match(line)
|
57
|
+
next if m.nil?
|
58
|
+
|
59
|
+
pid, rss, vsize, state, cputime, start, command = m.captures
|
60
|
+
start_s = DateTime.parse(start, 'Mmm DD HH:MM:ss YYYY').to_time.to_i
|
61
|
+
cputime_s = DateTime.parse(cputime, '%H:%M:%S')
|
62
|
+
cputime_seconds = (cputime_s.hour * 3600) + (cputime_s.minute * 60) + cputime_s.second
|
63
|
+
running = 0
|
64
|
+
case state[0]
|
65
|
+
when 'R'
|
66
|
+
state_s = 'ok'
|
67
|
+
running = 1
|
68
|
+
when 'S'
|
69
|
+
state_s = 'ok'
|
70
|
+
when 'I'
|
71
|
+
state_s = 'warning'
|
72
|
+
when 'T', 'U', 'Z'
|
73
|
+
state_s = 'critical'
|
74
|
+
else
|
75
|
+
state_s = 'unknown'
|
76
|
+
end
|
77
|
+
report(
|
78
|
+
service: "proc #{pid}-#{start_s}/rss",
|
79
|
+
state: state_s.to_s,
|
80
|
+
metric: rss.to_f,
|
81
|
+
description: command,
|
82
|
+
)
|
83
|
+
report(
|
84
|
+
service: "proc #{pid}-#{start_s}/vsize",
|
85
|
+
state: state_s.to_s,
|
86
|
+
metric: vsize.to_f,
|
87
|
+
description: command,
|
88
|
+
)
|
89
|
+
report(
|
90
|
+
service: "proc #{pid}-#{start_s}/running",
|
91
|
+
state: state_s.to_s,
|
92
|
+
metric: running.to_f,
|
93
|
+
description: command,
|
94
|
+
)
|
95
|
+
report(
|
96
|
+
service: "proc #{pid}-#{start_s}/cputime",
|
97
|
+
state: state_s.to_s,
|
98
|
+
metric: cputime_seconds,
|
99
|
+
description: command,
|
100
|
+
)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def tick
|
105
|
+
@check.call
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
require 'riemann/client'
|
6
|
+
|
7
|
+
module Riemann
|
8
|
+
module Tools
|
9
|
+
class RiemannClientWrapper
|
10
|
+
include Singleton
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@client = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure(options)
|
17
|
+
return self unless @client.nil?
|
18
|
+
|
19
|
+
r = Riemann::Client.new(
|
20
|
+
host: options[:host],
|
21
|
+
port: options[:port],
|
22
|
+
timeout: options[:timeout],
|
23
|
+
ssl: options[:tls],
|
24
|
+
key_file: options[:tls_key],
|
25
|
+
cert_file: options[:tls_cert],
|
26
|
+
ca_file: options[:tls_ca_cert],
|
27
|
+
ssl_verify: options[:tls_verify],
|
28
|
+
)
|
29
|
+
|
30
|
+
@client = if options[:tcp] || options[:tls]
|
31
|
+
r.tcp
|
32
|
+
else
|
33
|
+
r
|
34
|
+
end
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def <<(event)
|
39
|
+
@client << event
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,323 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.6.0
|
4
|
+
# from Racc grammar file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
|
9
|
+
|
10
|
+
require 'strscan'
|
11
|
+
|
12
|
+
module Riemann
|
13
|
+
module Tools
|
14
|
+
class UptimeParser < Racc::Parser
|
15
|
+
|
16
|
+
module_eval(<<'...end uptime_parser.y/module_eval...', 'uptime_parser.y', 43)
|
17
|
+
|
18
|
+
def parse(text)
|
19
|
+
s = StringScanner.new(text)
|
20
|
+
@tokens = []
|
21
|
+
|
22
|
+
until s.eos? do
|
23
|
+
case
|
24
|
+
when s.scan(/\n/) then # ignore
|
25
|
+
when s.scan(/\s+/) then # ignore
|
26
|
+
|
27
|
+
when s.scan(/:/) then @tokens << [':', s.matched]
|
28
|
+
when s.scan(/,/) then @tokens << [',', s.matched]
|
29
|
+
when s.scan(/\d+[,.]\d+/) then @tokens << [:FLOAT, s.matched.sub(',', '.').to_f]
|
30
|
+
when s.scan(/\d+/) then @tokens << [:INTEGER, s.matched.to_i]
|
31
|
+
when s.scan(/AM/) then @tokens << [:AM, s.matched]
|
32
|
+
when s.scan(/PM/) then @tokens << [:PM, s.matched]
|
33
|
+
when s.scan(/up/) then @tokens << [:UP, s.matched]
|
34
|
+
when s.scan(/days?/) then @tokens << [:DAYS, s.matched]
|
35
|
+
when s.scan(/hrs?/) then @tokens << [:HRS, s.matched]
|
36
|
+
when s.scan(/mins?/) then @tokens << [:MINS, s.matched]
|
37
|
+
when s.scan(/secs?/) then @tokens << [:SECS, s.matched]
|
38
|
+
when s.scan(/users?/) then @tokens << [:USERS, s.matched]
|
39
|
+
when s.scan(/load averages?:/) then @tokens << [:LOAD_AVERAGES, s.matched]
|
40
|
+
else
|
41
|
+
raise s.rest
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
do_parse
|
46
|
+
end
|
47
|
+
|
48
|
+
def next_token
|
49
|
+
@tokens.shift
|
50
|
+
end
|
51
|
+
...end uptime_parser.y/module_eval...
|
52
|
+
##### State transition tables begin ###
|
53
|
+
|
54
|
+
racc_action_table = [
|
55
|
+
29, 30, 24, 26, 27, 28, 26, 27, 28, 40,
|
56
|
+
41, 25, 31, 3, 25, 4, 6, 7, 8, 9,
|
57
|
+
15, 16, 18, 23, 32, 33, 34, 35, 36, 38,
|
58
|
+
39, 42, 43, 44, 45 ]
|
59
|
+
|
60
|
+
racc_action_check = [
|
61
|
+
16, 16, 15, 15, 15, 15, 23, 23, 23, 39,
|
62
|
+
39, 15, 16, 0, 23, 1, 2, 3, 4, 5,
|
63
|
+
6, 7, 9, 10, 17, 18, 24, 25, 31, 32,
|
64
|
+
38, 40, 41, 43, 44 ]
|
65
|
+
|
66
|
+
racc_action_pointer = [
|
67
|
+
2, 15, 12, 3, 18, 6, 9, 10, nil, 11,
|
68
|
+
12, nil, nil, nil, nil, -3, -2, 11, 16, nil,
|
69
|
+
nil, nil, nil, 0, 13, 16, nil, nil, nil, nil,
|
70
|
+
nil, 17, 19, nil, nil, nil, nil, nil, 18, -3,
|
71
|
+
19, 20, nil, 20, 22, nil ]
|
72
|
+
|
73
|
+
racc_action_default = [
|
74
|
+
-22, -22, -22, -22, -22, -22, -22, -22, 46, -22,
|
75
|
+
-22, -10, -11, -12, -13, -22, -2, -22, -22, -6,
|
76
|
+
-7, -8, -9, -22, -22, -22, -16, -17, -18, -3,
|
77
|
+
-4, -22, -22, -19, -14, -15, -5, -1, -22, -22,
|
78
|
+
-22, -22, -20, -22, -22, -21 ]
|
79
|
+
|
80
|
+
racc_goto_table = [
|
81
|
+
11, 12, 13, 14, 19, 20, 21, 22, 1, 2,
|
82
|
+
5, 17, 37, 10 ]
|
83
|
+
|
84
|
+
racc_goto_check = [
|
85
|
+
7, 8, 9, 10, 7, 8, 9, 10, 1, 2,
|
86
|
+
3, 4, 5, 6 ]
|
87
|
+
|
88
|
+
racc_goto_pointer = [
|
89
|
+
nil, 8, 9, 8, 2, -20, 7, -6, -5, -4,
|
90
|
+
-3 ]
|
91
|
+
|
92
|
+
racc_goto_default = [
|
93
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
94
|
+
nil ]
|
95
|
+
|
96
|
+
racc_reduce_table = [
|
97
|
+
0, 0, :racc_error,
|
98
|
+
6, 16, :_reduce_1,
|
99
|
+
3, 17, :_reduce_none,
|
100
|
+
4, 17, :_reduce_none,
|
101
|
+
4, 17, :_reduce_none,
|
102
|
+
5, 17, :_reduce_none,
|
103
|
+
3, 18, :_reduce_6,
|
104
|
+
3, 18, :_reduce_7,
|
105
|
+
3, 18, :_reduce_8,
|
106
|
+
3, 18, :_reduce_9,
|
107
|
+
2, 18, :_reduce_10,
|
108
|
+
2, 18, :_reduce_11,
|
109
|
+
2, 18, :_reduce_12,
|
110
|
+
2, 18, :_reduce_13,
|
111
|
+
3, 21, :_reduce_14,
|
112
|
+
3, 22, :_reduce_15,
|
113
|
+
2, 23, :_reduce_16,
|
114
|
+
2, 24, :_reduce_17,
|
115
|
+
2, 25, :_reduce_18,
|
116
|
+
2, 19, :_reduce_none,
|
117
|
+
4, 20, :_reduce_20,
|
118
|
+
6, 20, :_reduce_21 ]
|
119
|
+
|
120
|
+
racc_reduce_n = 22
|
121
|
+
|
122
|
+
racc_shift_n = 46
|
123
|
+
|
124
|
+
racc_token_table = {
|
125
|
+
false => 0,
|
126
|
+
:error => 1,
|
127
|
+
:AM => 2,
|
128
|
+
:PM => 3,
|
129
|
+
:UP => 4,
|
130
|
+
:DAYS => 5,
|
131
|
+
:HRS => 6,
|
132
|
+
:MINS => 7,
|
133
|
+
:SECS => 8,
|
134
|
+
:USERS => 9,
|
135
|
+
:LOAD_AVERAGES => 10,
|
136
|
+
:INTEGER => 11,
|
137
|
+
:FLOAT => 12,
|
138
|
+
"," => 13,
|
139
|
+
":" => 14 }
|
140
|
+
|
141
|
+
racc_nt_base = 15
|
142
|
+
|
143
|
+
racc_use_result_var = true
|
144
|
+
|
145
|
+
Racc_arg = [
|
146
|
+
racc_action_table,
|
147
|
+
racc_action_check,
|
148
|
+
racc_action_default,
|
149
|
+
racc_action_pointer,
|
150
|
+
racc_goto_table,
|
151
|
+
racc_goto_check,
|
152
|
+
racc_goto_default,
|
153
|
+
racc_goto_pointer,
|
154
|
+
racc_nt_base,
|
155
|
+
racc_reduce_table,
|
156
|
+
racc_token_table,
|
157
|
+
racc_shift_n,
|
158
|
+
racc_reduce_n,
|
159
|
+
racc_use_result_var ]
|
160
|
+
|
161
|
+
Racc_token_to_s_table = [
|
162
|
+
"$end",
|
163
|
+
"error",
|
164
|
+
"AM",
|
165
|
+
"PM",
|
166
|
+
"UP",
|
167
|
+
"DAYS",
|
168
|
+
"HRS",
|
169
|
+
"MINS",
|
170
|
+
"SECS",
|
171
|
+
"USERS",
|
172
|
+
"LOAD_AVERAGES",
|
173
|
+
"INTEGER",
|
174
|
+
"FLOAT",
|
175
|
+
"\",\"",
|
176
|
+
"\":\"",
|
177
|
+
"$start",
|
178
|
+
"target",
|
179
|
+
"time",
|
180
|
+
"uptime",
|
181
|
+
"users",
|
182
|
+
"load_averages",
|
183
|
+
"uptime_days",
|
184
|
+
"uptime_hr_min",
|
185
|
+
"uptime_hr",
|
186
|
+
"uptime_min",
|
187
|
+
"uptime_sec" ]
|
188
|
+
|
189
|
+
Racc_debug_parser = false
|
190
|
+
|
191
|
+
##### State transition tables end #####
|
192
|
+
|
193
|
+
# reduce 0 omitted
|
194
|
+
|
195
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 4)
|
196
|
+
def _reduce_1(val, _values, result)
|
197
|
+
result = { uptime: val[1], users: val[3], load_averages: val[5] }
|
198
|
+
result
|
199
|
+
end
|
200
|
+
.,.,
|
201
|
+
|
202
|
+
# reduce 2 omitted
|
203
|
+
|
204
|
+
# reduce 3 omitted
|
205
|
+
|
206
|
+
# reduce 4 omitted
|
207
|
+
|
208
|
+
# reduce 5 omitted
|
209
|
+
|
210
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 11)
|
211
|
+
def _reduce_6(val, _values, result)
|
212
|
+
result = val[1] + val[2]
|
213
|
+
result
|
214
|
+
end
|
215
|
+
.,.,
|
216
|
+
|
217
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 12)
|
218
|
+
def _reduce_7(val, _values, result)
|
219
|
+
result = val[1] + val[2]
|
220
|
+
result
|
221
|
+
end
|
222
|
+
.,.,
|
223
|
+
|
224
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 13)
|
225
|
+
def _reduce_8(val, _values, result)
|
226
|
+
result = val[1] + val[2]
|
227
|
+
result
|
228
|
+
end
|
229
|
+
.,.,
|
230
|
+
|
231
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 14)
|
232
|
+
def _reduce_9(val, _values, result)
|
233
|
+
result = val[1] + val[2]
|
234
|
+
result
|
235
|
+
end
|
236
|
+
.,.,
|
237
|
+
|
238
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 15)
|
239
|
+
def _reduce_10(val, _values, result)
|
240
|
+
result = val[1]
|
241
|
+
result
|
242
|
+
end
|
243
|
+
.,.,
|
244
|
+
|
245
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 16)
|
246
|
+
def _reduce_11(val, _values, result)
|
247
|
+
result = val[1]
|
248
|
+
result
|
249
|
+
end
|
250
|
+
.,.,
|
251
|
+
|
252
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 17)
|
253
|
+
def _reduce_12(val, _values, result)
|
254
|
+
result = val[1]
|
255
|
+
result
|
256
|
+
end
|
257
|
+
.,.,
|
258
|
+
|
259
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 18)
|
260
|
+
def _reduce_13(val, _values, result)
|
261
|
+
result = val[1]
|
262
|
+
result
|
263
|
+
end
|
264
|
+
.,.,
|
265
|
+
|
266
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 20)
|
267
|
+
def _reduce_14(val, _values, result)
|
268
|
+
result = val[0] * 86400
|
269
|
+
result
|
270
|
+
end
|
271
|
+
.,.,
|
272
|
+
|
273
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 22)
|
274
|
+
def _reduce_15(val, _values, result)
|
275
|
+
result = val[0] * 3600 + val[2] * 60
|
276
|
+
result
|
277
|
+
end
|
278
|
+
.,.,
|
279
|
+
|
280
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 24)
|
281
|
+
def _reduce_16(val, _values, result)
|
282
|
+
result = val[0] * 3600
|
283
|
+
result
|
284
|
+
end
|
285
|
+
.,.,
|
286
|
+
|
287
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 26)
|
288
|
+
def _reduce_17(val, _values, result)
|
289
|
+
result = val[0] * 60
|
290
|
+
result
|
291
|
+
end
|
292
|
+
.,.,
|
293
|
+
|
294
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 28)
|
295
|
+
def _reduce_18(val, _values, result)
|
296
|
+
result = val[0]
|
297
|
+
result
|
298
|
+
end
|
299
|
+
.,.,
|
300
|
+
|
301
|
+
# reduce 19 omitted
|
302
|
+
|
303
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 32)
|
304
|
+
def _reduce_20(val, _values, result)
|
305
|
+
result = { 1 => val[1], 5 => val[2], 15 => val[3] }
|
306
|
+
result
|
307
|
+
end
|
308
|
+
.,.,
|
309
|
+
|
310
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 33)
|
311
|
+
def _reduce_21(val, _values, result)
|
312
|
+
result = { 1 => val[1], 5 => val[3], 15 => val[5] }
|
313
|
+
result
|
314
|
+
end
|
315
|
+
.,.,
|
316
|
+
|
317
|
+
def _reduce_none(val, _values, result)
|
318
|
+
val[0]
|
319
|
+
end
|
320
|
+
|
321
|
+
end # class UptimeParser
|
322
|
+
end # module Tools
|
323
|
+
end # module Riemann
|