sensu 0.5.12 → 0.5.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/README.org +8 -5
- data/bin/sensu-api +1 -1
- data/bin/sensu-client +1 -1
- data/bin/sensu-server +1 -1
- data/lib/sensu/client.rb +5 -5
- data/lib/sensu/config.rb +21 -0
- data/lib/sensu/server.rb +11 -15
- data/sensu.gemspec +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sensu (0.
|
4
|
+
sensu (0.5.12)
|
5
5
|
amqp (= 0.7.4)
|
6
6
|
async_sinatra
|
7
7
|
em-hiredis
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
async_sinatra (0.5.0)
|
19
19
|
rack (>= 1.2.1)
|
20
20
|
sinatra (>= 1.0)
|
21
|
-
callsite (0.0.
|
21
|
+
callsite (0.0.6)
|
22
22
|
bundler (~> 1.0.0)
|
23
23
|
daemons (1.1.4)
|
24
24
|
em-hiredis (0.1.0)
|
@@ -30,12 +30,12 @@ GEM
|
|
30
30
|
eventmachine
|
31
31
|
eventmachine (0.12.10)
|
32
32
|
hiredis (0.3.2)
|
33
|
-
json (1.
|
33
|
+
json (1.6.1)
|
34
34
|
mime-types (1.16)
|
35
|
-
minitest (2.
|
36
|
-
rack (1.3.
|
35
|
+
minitest (2.6.0)
|
36
|
+
rack (1.3.3)
|
37
37
|
rake (0.9.2)
|
38
|
-
rest-client (1.6.
|
38
|
+
rest-client (1.6.7)
|
39
39
|
mime-types (>= 1.16)
|
40
40
|
sinatra (1.2.6)
|
41
41
|
rack (~> 1.1)
|
data/README.org
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
Check results are handled by user created handlers.
|
7
7
|
|
8
|
+
Documentation can be found [[https://github.com/sonian/sensu/wiki][here]].
|
9
|
+
|
8
10
|
* License
|
9
11
|
Sensu is released under the [[https://github.com/sonian/sensu/blob/master/MIT-LICENSE.txt][MIT license]].
|
10
12
|
|
@@ -19,19 +21,20 @@
|
|
19
21
|
*** A Client Will
|
20
22
|
- Have a set of attributes to describe it, including its responsibilities
|
21
23
|
- Send keep-alives to a server
|
22
|
-
- Subscribe to a
|
24
|
+
- Subscribe to a queue bound to a set of fanout exchanges, determined by its responsibilities
|
23
25
|
- Substitute tokens in check commands with their matching client attribute
|
26
|
+
- Report when it does not have a client attribute for token substitution
|
24
27
|
- Receive checks from subscriptions, execute them, and publish the results to a queue with its client name
|
25
28
|
- Not allow overlapping check executions of the same name
|
26
29
|
- Report when it is unaware of a check it received from a subscription
|
27
30
|
|
28
31
|
*** A Server Will
|
29
|
-
- Subscribe to a queue for check
|
30
|
-
-
|
31
|
-
-
|
32
|
+
- Subscribe to a queue for check results, another for keep-alives
|
33
|
+
- Pull keep-alives, storing client details
|
34
|
+
- Publish checks on defined intervals to their associated fanout exchanges
|
32
35
|
- Pull check results, storing the latest events for clients, a good result will flush a previous event for that client
|
33
36
|
- Create an event when it stops receiving keep-alives from a client, a new keep-alive for the client will clear the event
|
34
|
-
- Trigger a event handler,
|
37
|
+
- Trigger a event handler, either the default handler or one specified for the check, providing it with a JSON event file
|
35
38
|
|
36
39
|
*** An API Will
|
37
40
|
- List all current events
|
data/bin/sensu-api
CHANGED
data/bin/sensu-client
CHANGED
data/bin/sensu-server
CHANGED
data/lib/sensu/client.rb
CHANGED
@@ -71,11 +71,11 @@ module Sensu
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def setup_subscriptions
|
74
|
-
@
|
74
|
+
@check_queue = @amq.queue(UUIDTools::UUID.random_create.to_s, :exclusive => true)
|
75
75
|
@settings['client']['subscriptions'].each do |exchange|
|
76
|
-
@
|
76
|
+
@check_queue.bind(@amq.fanout(exchange))
|
77
77
|
end
|
78
|
-
@
|
78
|
+
@check_queue.subscribe do |check_json|
|
79
79
|
check = JSON.parse(check_json)
|
80
80
|
execute_check(check)
|
81
81
|
end
|
@@ -83,8 +83,8 @@ module Sensu
|
|
83
83
|
|
84
84
|
def monitor_queues
|
85
85
|
EM.add_periodic_timer(5) do
|
86
|
-
unless @
|
87
|
-
@
|
86
|
+
unless @check_queue.subscribed?
|
87
|
+
@check_queue.delete
|
88
88
|
EM.add_timer(1) do
|
89
89
|
setup_subscriptions
|
90
90
|
end
|
data/lib/sensu/config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
2
|
+
require 'optparse'
|
2
3
|
require 'json'
|
3
4
|
require 'uuidtools'
|
4
5
|
require 'amqp'
|
@@ -38,6 +39,26 @@ module Sensu
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
42
|
+
def self.read_arguments(arguments)
|
43
|
+
options = Hash.new
|
44
|
+
optparse = OptionParser.new do |opts|
|
45
|
+
opts.on('-h', '--help', 'Display this screen') do
|
46
|
+
puts opts
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
options[:worker] = false
|
50
|
+
opts.on('-w', '--worker', 'Only consume jobs, no check publishing (default: false)') do
|
51
|
+
options[:worker] = true
|
52
|
+
end
|
53
|
+
options[:config_file] = nil
|
54
|
+
opts.on('-c', '--config FILE', 'Sensu JSON config FILE (default: /etc/sensu/config.json)') do |file|
|
55
|
+
options[:config_file] = file
|
56
|
+
end
|
57
|
+
end
|
58
|
+
optparse.parse!(arguments)
|
59
|
+
options
|
60
|
+
end
|
61
|
+
|
41
62
|
def create_working_directory
|
42
63
|
begin
|
43
64
|
Dir.mkdir('/tmp/sensu')
|
data/lib/sensu/server.rb
CHANGED
@@ -3,7 +3,7 @@ require 'em-hiredis'
|
|
3
3
|
|
4
4
|
module Sensu
|
5
5
|
class Server
|
6
|
-
attr_accessor :redis
|
6
|
+
attr_accessor :redis, :is_worker
|
7
7
|
alias :redis_connection :redis
|
8
8
|
|
9
9
|
def self.run(options={})
|
@@ -15,8 +15,10 @@ module Sensu
|
|
15
15
|
server.setup_keepalives
|
16
16
|
server.setup_handlers
|
17
17
|
server.setup_results
|
18
|
-
server.
|
19
|
-
|
18
|
+
unless server.is_worker
|
19
|
+
server.setup_publisher
|
20
|
+
server.setup_keepalive_monitor
|
21
|
+
end
|
20
22
|
server.monitor_queues
|
21
23
|
|
22
24
|
Signal.trap('INT') do
|
@@ -33,6 +35,7 @@ module Sensu
|
|
33
35
|
config = Sensu::Config.new(:config_file => options[:config_file])
|
34
36
|
config.create_working_directory
|
35
37
|
@settings = config.settings
|
38
|
+
@is_worker = options[:worker]
|
36
39
|
end
|
37
40
|
|
38
41
|
def setup_logging
|
@@ -155,7 +158,6 @@ module Sensu
|
|
155
158
|
end
|
156
159
|
|
157
160
|
def setup_keepalive_monitor
|
158
|
-
result_queue = @amq.queue('results')
|
159
161
|
EM.add_periodic_timer(30) do
|
160
162
|
@redis.smembers('clients').callback do |clients|
|
161
163
|
clients.each do |client_id|
|
@@ -166,15 +168,15 @@ module Sensu
|
|
166
168
|
case
|
167
169
|
when time_since_last_check >= 180
|
168
170
|
result['check'].merge!({'status' => 2, 'output' => 'No keep-alive sent from host in over 180 seconds'})
|
169
|
-
result_queue.publish(result.to_json)
|
171
|
+
@result_queue.publish(result.to_json)
|
170
172
|
when time_since_last_check >= 120
|
171
173
|
result['check'].merge!({'status' => 1, 'output' => 'No keep-alive sent from host in over 120 seconds'})
|
172
|
-
result_queue.publish(result.to_json)
|
174
|
+
@result_queue.publish(result.to_json)
|
173
175
|
else
|
174
176
|
@redis.hexists('events:' + client_id, 'keepalive').callback do |exists|
|
175
177
|
if exists == 1
|
176
178
|
result['check'].merge!({'status' => 0, 'output' => 'Keep-alive sent from host'})
|
177
|
-
result_queue.publish(result.to_json)
|
179
|
+
@result_queue.publish(result.to_json)
|
178
180
|
end
|
179
181
|
end
|
180
182
|
end
|
@@ -187,16 +189,10 @@ module Sensu
|
|
187
189
|
def monitor_queues
|
188
190
|
EM.add_periodic_timer(5) do
|
189
191
|
unless @keepalive_queue.subscribed?
|
190
|
-
|
191
|
-
EM.add_timer(1) do
|
192
|
-
setup_keepalives
|
193
|
-
end
|
192
|
+
setup_keepalives
|
194
193
|
end
|
195
194
|
unless @result_queue.subscribed?
|
196
|
-
|
197
|
-
EM.add_timer(1) do
|
198
|
-
setup_results
|
199
|
-
end
|
195
|
+
setup_results
|
200
196
|
end
|
201
197
|
end
|
202
198
|
end
|
data/sensu.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.13
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sean Porter
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-09-
|
14
|
+
date: 2011-09-22 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: amqp
|