Permalink
Browse files

[api-updates] /info for providing sensu info such as version etc

  • Loading branch information...
1 parent ac1d8fc commit c3fd98377471ae73e48839e61280e3f8ab07f425 @portertech portertech committed Mar 5, 2012
Showing with 22 additions and 0 deletions.
  1. +9 −0 lib/sensu/api.rb
  2. +1 −0 lib/sensu/config.rb
  3. +12 −0 test/sensu_api_test.rb
View
@@ -46,6 +46,15 @@ def self.setup(options={})
content_type 'application/json'
end
+ aget '/info' do
+ response = {
+ :sensu => {
+ :version => Sensu::VERSION
+ }
+ }
+ body response.to_json
+ end
+
aget '/clients' do
$logger.debug('[clients] -- ' + request.ip + ' -- GET -- request for client list')
response = Array.new
View
@@ -12,6 +12,7 @@
require 'cabin'
require 'cabin/outputs/em/stdlib-logger'
+require File.join(File.dirname(__FILE__), '..', 'sensu')
require File.join(File.dirname(__FILE__), 'patches', 'ruby')
require File.join(File.dirname(__FILE__), 'patches', 'amqp')
View
@@ -9,6 +9,18 @@ def setup
@api = 'http://' + @settings.api.host + ':' + @settings.api.port.to_s
end
+ def test_get_info
+ Sensu::API.run_test(@options) do
+ http = EM::HttpRequest.new(@api + '/info').get
+ http.callback do
+ assert_equal(200, http.response_header.status)
+ info = JSON.parse(http.response)
+ assert_equal(Sensu::VERSION, info['sensu']['version'])
+ done
+ end
+ end
+ end
+
def test_get_events
Sensu::API.run_test(@options) do
http = EM::HttpRequest.new(@api + '/events').get

0 comments on commit c3fd983

Please sign in to comment.