sensu 0.6.4-x86-mswin32 → 0.6.5-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/sensu.rb +1 -1
  2. data/lib/sensu/api.rb +72 -37
  3. metadata +2 -2
data/lib/sensu.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sensu
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
data/lib/sensu/api.rb CHANGED
@@ -54,13 +54,53 @@ module Sensu
54
54
  end
55
55
  end
56
56
 
57
- aget '/client/:id' do |client|
57
+ aget '/client/:name' do |client|
58
58
  conn.redis.get('client:' + client).callback do |client_json|
59
59
  status 404 if client_json.nil?
60
60
  body client_json
61
61
  end
62
62
  end
63
63
 
64
+ adelete '/client/:name' do |client|
65
+ conn.redis.sismember('clients', client).callback do |client_exists|
66
+ unless client_exists == 0
67
+ conn.redis.exists('events:' + client).callback do |events_exist|
68
+ unless events_exist == 0
69
+ conn.redis.hgetall('events:' + client).callback do |events|
70
+ Hash[*events].keys.each do |check_name|
71
+ check = {'name' => check_name, 'issued' => Time.now.to_i, 'status' => 0, 'output' => 'Client is being removed'}
72
+ conn.amq.queue('results').publish({'client' => client, 'check' => check}.to_json)
73
+ end
74
+ EM.add_timer(5) do
75
+ conn.redis.srem('clients', client)
76
+ conn.redis.del('events:' + client)
77
+ conn.redis.del('client:' + client)
78
+ end
79
+ end
80
+ else
81
+ conn.redis.srem('clients', client)
82
+ conn.redis.del('events:' + client)
83
+ conn.redis.del('client:' + client)
84
+ end
85
+ status 204
86
+ body nil
87
+ end
88
+ else
89
+ status 404
90
+ body nil
91
+ end
92
+ end
93
+ end
94
+
95
+ aget '/event/:client/:check' do |client, check|
96
+ conn.redis.hgetall('events:' + client).callback do |events|
97
+ client_events = Hash[*events]
98
+ event = client_events[check]
99
+ status 404 if event.nil?
100
+ body event
101
+ end
102
+ end
103
+
64
104
  aget '/events' do
65
105
  current_events = Hash.new
66
106
  conn.redis.smembers('clients').callback do |clients|
@@ -81,39 +121,36 @@ module Sensu
81
121
  end
82
122
  end
83
123
 
84
- adelete '/client/:id' do |client|
85
- conn.redis.sismember('clients', client).callback do |client_exists|
86
- unless client_exists == 0
87
- conn.redis.exists('events:' + client).callback do |events_exist|
88
- unless events_exist == 0
89
- conn.redis.hgetall('events:' + client).callback do |events|
90
- Hash[*events].keys.each do |check_name|
91
- check = {'name' => check_name, 'issued' => Time.now.to_i, 'status' => 0, 'output' => 'client is being removed...'}
92
- conn.amq.queue('results').publish({'client' => client, 'check' => check}.to_json)
93
- end
94
- EM.add_timer(8) do
95
- conn.redis.srem('clients', client)
96
- conn.redis.del('events:' + client)
97
- conn.redis.del('client:' + client)
98
- end
99
- end
100
- else
101
- conn.redis.srem('clients', client)
102
- conn.redis.del('events:' + client)
103
- conn.redis.del('client:' + client)
104
- end
124
+ apost '/stash/*' do |path|
125
+ conn.redis.set('stash:' + path, params[:data]).callback do
126
+ status 201
127
+ body nil
128
+ end
129
+ end
130
+
131
+ aget '/stash/*' do |path|
132
+ conn.redis.get('stash:' + path).callback do |stash|
133
+ status 404 if stash.nil?
134
+ body stash
135
+ end
136
+ end
137
+
138
+ adelete '/stash/*' do |path|
139
+ conn.redis.exists('stash:' + path).callback do |stash_exist|
140
+ unless stash_exist == 0
141
+ conn.redis.del('stash:' + path).callback do
105
142
  status 204
106
- body ''
143
+ body nil
107
144
  end
108
145
  else
109
146
  status 404
110
- body ''
147
+ body nil
111
148
  end
112
149
  end
113
150
  end
114
151
 
115
- apost '/test/client' do
116
- attributes = '{
152
+ apost '/test' do
153
+ client = '{
117
154
  "name": "test",
118
155
  "address": "localhost",
119
156
  "subscriptions": [
@@ -121,17 +158,15 @@ module Sensu
121
158
  "bar"
122
159
  ]
123
160
  }'
124
- conn.redis.set('client:test', attributes).callback do
125
- conn.redis.sadd('clients', 'test')
126
- status 201
127
- body ''
128
- end
129
- end
130
-
131
- apost '/test/event' do
132
- conn.redis.hset('events:test', 'test', {'status' => 2, 'output' => 'CRITICAL :: test', 'occurrences' => 1}.to_json).callback do
133
- status 201
134
- body ''
161
+ conn.redis.set('client:test', client).callback do
162
+ conn.redis.sadd('clients', 'test').callback do
163
+ conn.redis.hset('events:test', 'test', {'status' => 2, 'output' => 'CRITICAL', 'occurrences' => 1}.to_json).callback do
164
+ conn.redis.set('stash:test/test', '{"key": "value"}').callback do
165
+ status 201
166
+ body nil
167
+ end
168
+ end
169
+ end
135
170
  end
136
171
  end
137
172
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sensu
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.4
5
+ version: 0.6.5
6
6
  platform: x86-mswin32
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-27 00:00:00 Z
14
+ date: 2011-09-28 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: eventmachine