hinoki 1.1.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/lib/hinoki/aggregates.rb +4 -6
- data/lib/hinoki/base.rb +9 -5
- data/lib/hinoki/checks.rb +3 -5
- data/lib/hinoki/clients.rb +4 -6
- data/lib/hinoki/connection.rb +2 -2
- data/lib/hinoki/events.rb +3 -5
- data/lib/hinoki/stashes.rb +4 -6
- data/lib/hinoki/version.rb +1 -1
- data/spec/hinoki/aggregates_spec.rb +0 -0
- data/spec/hinoki/checks_spec.rb +0 -0
- data/spec/hinoki/clients_spec.rb +17 -0
- data/spec/hinoki/events_spec.rb +0 -0
- data/spec/hinoki/generic_spec.rb +0 -0
- data/spec/hinoki/stashes_spec.rb +0 -0
- data/spec/hinoki_spec.rb +4 -0
- data/spec/spec_helper.rb +2 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8446fd8cc41684f7bd2063be59ab013aa7b6b9ab
|
4
|
+
data.tar.gz: c1137cfa77ed25ad24454e1f029fa7c911ab1573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c02c402318119a587eab2dca2bc7bbb414138ddefa4989364d8fc061bb2cb9cfcc858c2fdf219a49b8a036bee9dfd647b7834e7205604e442f317a5c4b5d69ab
|
7
|
+
data.tar.gz: 37fcd0ad903e100fd9c1537267770a15dfe1edf28f5b2a7820493c1931e74df5f9d7971f20d6e1c9593e0f5b6a9e2e1ca85fe8821d7a4ac01d7fe23719076dc8
|
data/lib/hinoki/aggregates.rb
CHANGED
@@ -5,15 +5,13 @@ require 'hinoki/connection'
|
|
5
5
|
class Hinoki
|
6
6
|
module Aggregates
|
7
7
|
|
8
|
-
@conn = Hinoki::Connection.new
|
9
|
-
|
10
8
|
# Return a list of all aggregates
|
11
9
|
def self.all(limit=nil, offset=nil)
|
12
10
|
url = "/aggregates"
|
13
11
|
if limit then url.append("?limit=#{limit}") end
|
14
12
|
if offset then url.append("&offset=#{offset}") end
|
15
13
|
|
16
|
-
return
|
14
|
+
return Hinoki.conn.get(url)
|
17
15
|
end
|
18
16
|
|
19
17
|
# Return a specific aggregate check
|
@@ -21,12 +19,12 @@ class Hinoki
|
|
21
19
|
url = "/aggregates/#{name}"
|
22
20
|
if age then url.append("?age=#{age}") end
|
23
21
|
|
24
|
-
return
|
22
|
+
return Hinoki.conn.get(url)
|
25
23
|
end
|
26
24
|
|
27
25
|
# Delete an aggregate check
|
28
26
|
def self.delete(name)
|
29
|
-
return
|
27
|
+
return Hinoki.conn.delete("/aggregates/#{name}")
|
30
28
|
end
|
31
29
|
|
32
30
|
# Returns the list of aggregates
|
@@ -40,7 +38,7 @@ class Hinoki
|
|
40
38
|
url.append("?results=#{results}")
|
41
39
|
end
|
42
40
|
|
43
|
-
return
|
41
|
+
return Hinoki.conn.get(url)
|
44
42
|
end
|
45
43
|
|
46
44
|
end
|
data/lib/hinoki/base.rb
CHANGED
@@ -10,8 +10,8 @@ require 'hinoki/stashes'
|
|
10
10
|
class Hinoki
|
11
11
|
attr_accessor(:aggregates, :clients, :checks, :events, :stashes)
|
12
12
|
|
13
|
-
def initialize
|
14
|
-
|
13
|
+
def initialize(host=nil, port=nil)
|
14
|
+
@@conn = Hinoki::Connection.new(host, port)
|
15
15
|
@aggregates = Hinoki::Aggregates
|
16
16
|
@checks = Hinoki::Checks
|
17
17
|
@clients = Hinoki::Clients
|
@@ -19,14 +19,18 @@ class Hinoki
|
|
19
19
|
@stashes = Hinoki::Stashes
|
20
20
|
end
|
21
21
|
|
22
|
+
# Helper for modules to grab onto the connection
|
23
|
+
def self.conn
|
24
|
+
@@conn
|
25
|
+
end
|
26
|
+
|
22
27
|
# Delivers information about Sensu and RabbitMQ performance
|
23
28
|
def health(consumers=1, messages=1)
|
24
|
-
return
|
29
|
+
return self.conn.get("/health?consumers=#{consumers}&messages=#{messages}")
|
25
30
|
end
|
26
31
|
|
27
32
|
# Metadata about the Sensu installation
|
28
33
|
def info
|
29
|
-
return
|
34
|
+
return self.conn.get('/info')
|
30
35
|
end
|
31
|
-
|
32
36
|
end
|
data/lib/hinoki/checks.rb
CHANGED
@@ -5,23 +5,21 @@ require 'hinoki/connection'
|
|
5
5
|
class Hinoki
|
6
6
|
module Checks
|
7
7
|
|
8
|
-
@conn = Hinoki::Connection.new
|
9
|
-
|
10
8
|
# Lists all checks
|
11
9
|
def self.all
|
12
|
-
return
|
10
|
+
return Hinoki.conn.get('/checks')
|
13
11
|
end
|
14
12
|
|
15
13
|
# Returns info about a specific check
|
16
14
|
def self.by_name(check)
|
17
|
-
return
|
15
|
+
return Hinoki.conn.get("/checks/#{check}")
|
18
16
|
end
|
19
17
|
|
20
18
|
# Request a check to be run
|
21
19
|
def self.request(check, subscribers=[])
|
22
20
|
payload = JSON.generate({check: check, subscribers: subscribers})
|
23
21
|
|
24
|
-
return
|
22
|
+
return Hinoki.conn.post("/checks", payload)
|
25
23
|
end
|
26
24
|
|
27
25
|
end
|
data/lib/hinoki/clients.rb
CHANGED
@@ -5,30 +5,28 @@ require 'hinoki/connection'
|
|
5
5
|
class Hinoki
|
6
6
|
module Clients
|
7
7
|
|
8
|
-
@conn = Hinoki::Connection.new
|
9
|
-
|
10
8
|
# Retrieves list of all clients
|
11
9
|
def self.all(limit=nil, offset=nil)
|
12
10
|
url = "/clients"
|
13
11
|
if limit then url.append("?limit=#{limit}") end
|
14
12
|
if offset then url.append("&offset=#{offset}") end
|
15
13
|
|
16
|
-
return
|
14
|
+
return Hinoki.conn.get(url)
|
17
15
|
end
|
18
16
|
|
19
17
|
# Gets info about a specific client
|
20
18
|
def self.by_name(client)
|
21
|
-
return
|
19
|
+
return Hinoki.conn.get("/clients/#{client}")
|
22
20
|
end
|
23
21
|
|
24
22
|
# Deletes a client (and resolves its events)
|
25
23
|
def self.delete(client)
|
26
|
-
return
|
24
|
+
return Hinoki.conn.delete("/clients/#{client}")
|
27
25
|
end
|
28
26
|
|
29
27
|
# Gets recent history of this client's status
|
30
28
|
def self.history(client)
|
31
|
-
return
|
29
|
+
return Hinoki.conn.get("/clients/#{client}/history")
|
32
30
|
end
|
33
31
|
|
34
32
|
end
|
data/lib/hinoki/connection.rb
CHANGED
@@ -7,9 +7,9 @@ require 'hinoki/config'
|
|
7
7
|
class Hinoki
|
8
8
|
class Connection
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize(host=nil, port=nil)
|
11
11
|
@config = Hinoki::Config.new
|
12
|
-
@http = Net::HTTP.new(@config.host, @config.port)
|
12
|
+
@http = Net::HTTP.new(host || @config.host, port || @config.port)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Wrapper around Net::HTTP.get
|
data/lib/hinoki/events.rb
CHANGED
@@ -5,21 +5,19 @@ require 'hinoki/connection'
|
|
5
5
|
class Hinoki
|
6
6
|
module Events
|
7
7
|
|
8
|
-
@conn = Hinoki::Connection.new
|
9
|
-
|
10
8
|
# Lists all events
|
11
9
|
def self.all
|
12
|
-
return
|
10
|
+
return Hinoki.conn.get('/events')
|
13
11
|
end
|
14
12
|
|
15
13
|
# Returns events associated with the given client
|
16
14
|
def self.for_client(client)
|
17
|
-
return
|
15
|
+
return Hinoki.conn.get("/events/#{client}")
|
18
16
|
end
|
19
17
|
|
20
18
|
# Clears an event from Sensu
|
21
19
|
def self.resolve(client, check)
|
22
|
-
return
|
20
|
+
return Hinoki.conn.delete("/events/#{client}/#{check}")
|
23
21
|
end
|
24
22
|
|
25
23
|
end
|
data/lib/hinoki/stashes.rb
CHANGED
@@ -6,15 +6,13 @@ require 'hinoki/connection'
|
|
6
6
|
class Hinoki
|
7
7
|
module Stashes
|
8
8
|
|
9
|
-
@conn = Hinoki::Connection.new
|
10
|
-
|
11
9
|
# Lists all stashes
|
12
10
|
def self.all(limit=nil, offset=nil)
|
13
11
|
url = "/stashes"
|
14
12
|
if limit then url.append("?limit=#{limit}") end
|
15
13
|
if offset then url.append("&offset=#{offset}") end
|
16
14
|
|
17
|
-
return
|
15
|
+
return Hinoki.conn.get(url)
|
18
16
|
end
|
19
17
|
|
20
18
|
# Add a new stash (JSON formatted)
|
@@ -25,17 +23,17 @@ class Hinoki
|
|
25
23
|
post = Net::HTTP::Post.new('/stashes')
|
26
24
|
post.body=JSON.generate(hash)
|
27
25
|
|
28
|
-
return
|
26
|
+
return Hinoki.conn.request(post)
|
29
27
|
end
|
30
28
|
|
31
29
|
# Get information about a specific stash
|
32
30
|
def self.by_name(stash)
|
33
|
-
return
|
31
|
+
return Hinoki.conn.get("/stashes/#{stash}")
|
34
32
|
end
|
35
33
|
|
36
34
|
# Remove a stash
|
37
35
|
def self.delete(stash)
|
38
|
-
return
|
36
|
+
return Hinoki.conn.delete("/stashes/#{stash}")
|
39
37
|
end
|
40
38
|
|
41
39
|
end
|
data/lib/hinoki/version.rb
CHANGED
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe Hinoki::Clients do
|
5
|
+
before do
|
6
|
+
@hinoki = Hinoki.new(host: 'hinoki.test', port: 4567)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#all' do
|
10
|
+
it 'should return a list of all clients' do
|
11
|
+
stub_request(:get, "http://hinoki.test:4567/clients")
|
12
|
+
|
13
|
+
@hinoki.clients.all.should be_a(Array)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
data/spec/hinoki_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hinoki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A programmatic CLI utility for interacting with the Sensu API
|
14
14
|
email: jake.davis5989@gmail.com
|
@@ -29,6 +29,14 @@ files:
|
|
29
29
|
- lib/hinoki/events.rb
|
30
30
|
- lib/hinoki/stashes.rb
|
31
31
|
- lib/hinoki/version.rb
|
32
|
+
- spec/hinoki/aggregates_spec.rb
|
33
|
+
- spec/hinoki/checks_spec.rb
|
34
|
+
- spec/hinoki/clients_spec.rb
|
35
|
+
- spec/hinoki/events_spec.rb
|
36
|
+
- spec/hinoki/generic_spec.rb
|
37
|
+
- spec/hinoki/stashes_spec.rb
|
38
|
+
- spec/hinoki_spec.rb
|
39
|
+
- spec/spec_helper.rb
|
32
40
|
homepage: http://github.com/jakedavis/hinoki
|
33
41
|
licenses:
|
34
42
|
- Apache 2.0
|