icinga-rest 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source :rubygems
2
2
  gem "json"
3
+ gem "addressable"
3
4
  group :development do
4
5
  gem "ruby-debug"
5
6
  gem "rdoc"
data/Gemfile.lock CHANGED
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ addressable (2.2.6)
4
5
  columnize (0.3.2)
5
6
  diff-lcs (1.1.3)
6
7
  gem-this (0.3.7)
@@ -25,6 +26,7 @@ PLATFORMS
25
26
  ruby
26
27
 
27
28
  DEPENDENCIES
29
+ addressable
28
30
  gem-this
29
31
  json
30
32
  rdoc
data/Rakefile CHANGED
@@ -29,7 +29,7 @@ spec = Gem::Specification.new do |s|
29
29
 
30
30
  # Change these as appropriate
31
31
  s.name = "icinga-rest"
32
- s.version = "0.1.0"
32
+ s.version = "0.1.1"
33
33
  s.summary = "Simple, basic access to the Icinga REST API"
34
34
  s.author = "David Salgado"
35
35
  s.email = "david@digitalronin.com"
@@ -49,6 +49,7 @@ spec = Gem::Specification.new do |s|
49
49
  # If you want to depend on other gems, add them here, along with any
50
50
  # relevant versions
51
51
  s.add_dependency("json")
52
+ s.add_dependency("addressable")
52
53
 
53
54
  # If your tests use any gems, include them here
54
55
  s.add_development_dependency("rspec")
data/Readme.markdown CHANGED
@@ -28,10 +28,6 @@ Requirements
28
28
 
29
29
  You must have enabled the REST API on your Icinga server (and configured the hosts and services to be monitored, of course)
30
30
 
31
- Any box that runs this check will need the wget program in /usr/bin/wget
32
-
33
- wget is used instead of a nice ruby http library because the URLs to access the Icinga REST API are not valid http URLs, so all the libraries I tried barf on them. wget is more forgiving.
34
-
35
31
  MIT License
36
32
  ===========
37
33
 
data/lib/icinga_rest.rb CHANGED
@@ -4,6 +4,8 @@ end
4
4
 
5
5
  require 'rubygems'
6
6
  require 'json'
7
+ require 'net/http'
8
+ require 'addressable/uri'
7
9
 
8
10
  libdir = File.join(File.dirname(__FILE__), 'icinga_rest')
9
11
 
@@ -8,8 +8,6 @@ class IcingaRest::Request
8
8
  :count_column, # count this column to produce the total
9
9
  :output # json|xml
10
10
 
11
- WGET = '/usr/bin/wget'
12
-
13
11
  def initialize(params)
14
12
  @host = params[:host]
15
13
  @target = params[:target]
@@ -19,13 +17,13 @@ class IcingaRest::Request
19
17
  @output = params[:output]
20
18
  end
21
19
 
22
- # It would be nicer to use Net::HTTP, or something, but the
23
- # URLs required by the Icinga API are not well-formed, and
24
- # the URI library, used by most of the ruby http libs, barfs.
25
- # So, we shell out to wget, which is more tolerant.
26
- # Fugly, but functional.
20
+ # The standard URI library blows up with the malformed URLs
21
+ # required to access the Icinga REST API, but addressable
22
+ # works fine.
27
23
  def get
28
- `#{WGET} -q -O - '#{to_url}'`
24
+ uri = Addressable::URI.parse to_url
25
+ r = Net::HTTP.get_response uri.normalize
26
+ r.code == '200' ? r.body : ''
29
27
  end
30
28
 
31
29
  def to_url
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icinga-rest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Salgado
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-08 00:00:00 Z
18
+ date: 2011-10-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: json
@@ -32,7 +32,7 @@ dependencies:
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: rspec
35
+ name: addressable
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
@@ -43,10 +43,10 @@ dependencies:
43
43
  segments:
44
44
  - 0
45
45
  version: "0"
46
- type: :development
46
+ type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: ruby-debug
49
+ name: rspec
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  none: false
@@ -59,6 +59,20 @@ dependencies:
59
59
  version: "0"
60
60
  type: :development
61
61
  version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: ruby-debug
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :development
75
+ version_requirements: *id004
62
76
  description: Use the Icinga REST API to count hosts with services in a given state
63
77
  email: david@digitalronin.com
64
78
  executables: []