icinga 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -1
- data/icinga.gemspec +2 -0
- data/lib/icinga/server.rb +15 -2
- data/lib/icinga/version.rb +1 -1
- data/test/icinga/server_spec.rb +5 -0
- metadata +16 -5
data/README.md
CHANGED
data/icinga.gemspec
CHANGED
data/lib/icinga/server.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module Icinga
|
4
5
|
class Server
|
@@ -10,11 +11,23 @@ module Icinga
|
|
10
11
|
}
|
11
12
|
|
12
13
|
def connection
|
13
|
-
@conn ||= Net::HTTP.new(@host, @port)
|
14
|
+
@conn ||= Net::HTTP.new(@options[:host], @options[:port])
|
14
15
|
end
|
15
16
|
|
16
17
|
def new_request(path)
|
17
|
-
Net::HTTP::Get.new(path)
|
18
|
+
req = Net::HTTP::Get.new(path)
|
19
|
+
req.basic_auth @options[:user], @options[:password] if @options[:user]
|
20
|
+
req
|
21
|
+
end
|
22
|
+
|
23
|
+
def hosts
|
24
|
+
resp = connection.request(new_request("/icinga/cgi-bin/status.cgi?hostgroup=all&style=hostdetail&jsonoutput"))
|
25
|
+
JSON.parse(resp.body)
|
26
|
+
end
|
27
|
+
|
28
|
+
def services
|
29
|
+
resp = connection.request(new_request("/icinga/cgi-bin/status.cgi?host=all&style=servicedetail&jsonoutput"))
|
30
|
+
JSON.parse(resp.body)
|
18
31
|
end
|
19
32
|
|
20
33
|
def initialize(options={})
|
data/lib/icinga/version.rb
CHANGED
data/test/icinga/server_spec.rb
CHANGED
@@ -21,4 +21,9 @@ describe Icinga::Server do
|
|
21
21
|
it "should create a request" do
|
22
22
|
@icinga.new_request("/").should be_kind_of(Net::HTTP::Get)
|
23
23
|
end
|
24
|
+
|
25
|
+
it "should set basic auth" do
|
26
|
+
@icinga.options[:user] = "Foo"
|
27
|
+
@icinga.new_request("/").get_fields("Authorization").first.should match(/^Basic\s.*/)
|
28
|
+
end
|
24
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icinga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-12-06 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &20152660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *20152660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &20152040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,18 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *20152040
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
requirement: &20151460 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *20151460
|
36
47
|
description: Facilitates communication with Icinga servers.
|
37
48
|
email:
|
38
49
|
- jbussdieker@gmail.com
|