riemann-tools 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +15 -0
- data/.github/workflows/codeql-analysis.yml +72 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +40 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +62 -2
- data/README.markdown +8 -24
- data/Rakefile +14 -5
- data/SECURITY.md +42 -0
- data/bin/riemann-apache-status +3 -94
- data/bin/riemann-bench +4 -67
- data/bin/riemann-cloudant +3 -54
- data/bin/riemann-consul +3 -102
- data/bin/riemann-dir-files-count +3 -51
- data/bin/riemann-dir-space +3 -51
- data/bin/riemann-diskstats +3 -91
- data/bin/riemann-fd +4 -63
- data/bin/riemann-freeswitch +4 -116
- data/bin/riemann-haproxy +3 -54
- data/bin/riemann-health +3 -344
- data/bin/riemann-kvminstance +4 -19
- data/bin/riemann-memcached +3 -33
- data/bin/riemann-net +3 -105
- data/bin/riemann-nginx-status +3 -80
- data/bin/riemann-ntp +3 -34
- data/bin/riemann-portcheck +3 -37
- data/bin/riemann-proc +3 -104
- data/bin/riemann-varnish +3 -50
- data/bin/riemann-wrapper +75 -0
- data/bin/riemann-zookeeper +3 -37
- 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 +478 -0
- data/lib/riemann/tools/kvm.rb +23 -0
- data/lib/riemann/tools/memcached.rb +38 -0
- data/lib/riemann/tools/net.rb +105 -0
- data/lib/riemann/tools/nginx_status.rb +86 -0
- data/lib/riemann/tools/ntp.rb +42 -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 +31 -52
- data/riemann-tools.gemspec +8 -2
- data/tools/riemann-aws/{Rakefile.rb → Rakefile} +8 -9
- data/tools/riemann-aws/bin/riemann-aws-billing +4 -83
- data/tools/riemann-aws/bin/riemann-aws-rds-status +4 -50
- data/tools/riemann-aws/bin/riemann-aws-sqs-status +4 -40
- data/tools/riemann-aws/bin/riemann-aws-status +4 -67
- data/tools/riemann-aws/bin/riemann-elb-metrics +4 -163
- data/tools/riemann-aws/bin/riemann-s3-list +4 -78
- data/tools/riemann-aws/bin/riemann-s3-status +4 -95
- 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.rb → Rakefile} +8 -9
- data/tools/riemann-chronos/bin/riemann-chronos +3 -139
- data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +157 -0
- data/tools/riemann-docker/{Rakefile.rb → Rakefile} +7 -8
- data/tools/riemann-docker/bin/riemann-docker +4 -213
- data/tools/riemann-docker/lib/riemann/tools/docker.rb +200 -0
- data/tools/riemann-elasticsearch/{Rakefile.rb → Rakefile} +8 -9
- data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +3 -161
- data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +170 -0
- data/tools/riemann-marathon/{Rakefile.rb → Rakefile} +8 -9
- data/tools/riemann-marathon/bin/riemann-marathon +3 -142
- data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +159 -0
- data/tools/riemann-mesos/{Rakefile.rb → Rakefile} +8 -9
- data/tools/riemann-mesos/bin/riemann-mesos +3 -126
- data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +142 -0
- data/tools/riemann-munin/{Rakefile.rb → Rakefile} +7 -8
- data/tools/riemann-munin/bin/riemann-munin +3 -32
- data/tools/riemann-munin/lib/riemann/tools/munin.rb +37 -0
- data/tools/riemann-rabbitmq/{Rakefile.rb → Rakefile} +8 -9
- data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +3 -264
- data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +269 -0
- data/tools/riemann-riak/{Rakefile.rb → Rakefile} +7 -8
- data/tools/riemann-riak/bin/riemann-riak +3 -326
- 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 +112 -16
- 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
@@ -1,152 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
Process.setproctitle($0)
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../vodpod-common/lib")
|
5
|
-
require 'rubygems'
|
6
|
-
require 'vodpod-common'
|
7
|
-
require 'vodpod/alerts'
|
8
|
-
require 'vodpod/starling'
|
9
|
-
require 'net/http'
|
10
|
-
require 'yajl/json_gem'
|
11
|
-
|
12
|
-
class RiakStatus
|
13
|
-
PORT = 8098
|
14
|
-
PATH = '/stats'
|
15
|
-
INTERVAL = 10
|
16
|
-
|
17
|
-
FSM_LIMITS = {
|
18
|
-
:get => {
|
19
|
-
50 => 1000,
|
20
|
-
95 => 2000,
|
21
|
-
99 => 10000
|
22
|
-
},
|
23
|
-
:put => {
|
24
|
-
50 => 1000,
|
25
|
-
95 => 2000,
|
26
|
-
99 => 10000
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
def initialize(opts = {})
|
31
|
-
@host = opts[:host] || `hostname`.chomp
|
32
|
-
@port = opts[:port] || PORT
|
33
|
-
@path = opts[:path] || PATH
|
34
|
-
end
|
35
|
-
|
36
|
-
def alert(subservice, state, metric, description)
|
37
|
-
Vodpod.alert(
|
38
|
-
:service => "riak #{subservice}",
|
39
|
-
:state => state,
|
40
|
-
:metric => metric,
|
41
|
-
:description => description
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def check_ring
|
46
|
-
str = `#{File.expand_path(File.dirname(__FILE__))}/ringready.erl riak@#{`hostname`}`.chomp
|
47
|
-
if str =~ /^TRUE/
|
48
|
-
alert 'ring', :ok, nil, str
|
49
|
-
else
|
50
|
-
alert 'ring', :warning, nil, str
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def check_keys
|
55
|
-
keys = `#{File.expand_path(File.dirname(__FILE__))}/key_count.erl riak@#{`hostname`}`.chomp
|
56
|
-
if keys =~ /^\d+$/
|
57
|
-
alert 'keys', :ok, keys.to_i, keys
|
58
|
-
else
|
59
|
-
alert 'keys', :error, nil, keys
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def check_disk
|
64
|
-
gb = `du -s /var/lib/riak/bitcask/`.split(/\s+/).first.to_i / (1024.0**2)
|
65
|
-
alert 'disk', :ok, gb, "#{gb} GB in bitcask"
|
66
|
-
end
|
67
|
-
|
68
|
-
# Returns the riak stat for the given fsm type and percentile.
|
69
|
-
def fsm_stat(type, percentile)
|
70
|
-
"node_#{type}_fsm_time_#{percentile == 50 ? 'median' : percentile}"
|
71
|
-
end
|
72
|
-
|
73
|
-
# Returns the alerts state for the given fsm.
|
74
|
-
def fsm_state(type, percentile, val)
|
75
|
-
limit = FSM_LIMITS[type][percentile]
|
76
|
-
case val
|
77
|
-
when 0 .. limit
|
78
|
-
:ok
|
79
|
-
when limit .. limit * 2
|
80
|
-
:warning
|
81
|
-
else
|
82
|
-
:critical
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def check_stats
|
87
|
-
begin
|
88
|
-
res = Net::HTTP.start(@host, @port) do |http|
|
89
|
-
http.get('/stats')
|
90
|
-
end
|
91
|
-
rescue => e
|
92
|
-
Vodpod.alert(
|
93
|
-
:service => 'riak',
|
94
|
-
:state => :critical,
|
95
|
-
:description => "error fetching /stats: #{e.class}, #{e.message}"
|
96
|
-
)
|
97
|
-
return
|
98
|
-
end
|
99
|
-
|
100
|
-
if res.code.to_i == 200
|
101
|
-
stats = JSON.parse(res.body)
|
102
|
-
else
|
103
|
-
Vodpod.alert(
|
104
|
-
:service => 'riak',
|
105
|
-
:state => :critical,
|
106
|
-
:description => "stats returned HTTP #{res.code}:\n\n#{res.body}"
|
107
|
-
)
|
108
|
-
return
|
109
|
-
end
|
110
|
-
|
111
|
-
Vodpod.alert(
|
112
|
-
:service => 'riak',
|
113
|
-
:state => :ok
|
114
|
-
)
|
115
|
-
|
116
|
-
# Gets/puts/rr
|
117
|
-
[
|
118
|
-
'vnode_gets',
|
119
|
-
'vnode_puts',
|
120
|
-
'node_gets',
|
121
|
-
'node_puts',
|
122
|
-
'read_repairs'
|
123
|
-
].each do |s|
|
124
|
-
alert s, :ok, stats[s]/60.0, "#{stats[s]/60.0}/sec"
|
125
|
-
end
|
126
|
-
|
127
|
-
# FSMs
|
128
|
-
[:get, :put].each do |type|
|
129
|
-
[50, 95, 99].each do |percentile|
|
130
|
-
val = stats[fsm_stat(type, percentile)] || 0
|
131
|
-
val = 0 if val == 'undefined'
|
132
|
-
val /= 1000.0 # Convert us to ms
|
133
|
-
state = fsm_state(type, percentile, val)
|
134
|
-
alert "#{type} #{percentile}", state, val, "#{val} ms"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def run
|
140
|
-
loop do
|
141
|
-
# check_keys
|
142
|
-
check_stats
|
143
|
-
check_ring
|
144
|
-
check_disk
|
145
|
-
sleep INTERVAL
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
if $0 == __FILE__
|
151
|
-
RiakStatus.new.run
|
152
|
-
end
|