Class: Icinga::Server
- Inherits:
-
Object
- Object
- Icinga::Server
- Defined in:
- lib/icinga/server.rb
Constant Summary collapse
- @@default_options =
{ :host => "localhost", :port => 80, :remote_path => "/icinga/cgi-bin/status.cgi", :format => "json", }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #connection ⇒ Object
- #hosts ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #new_request(path) ⇒ Object
- #services ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
32 33 34 |
# File 'lib/icinga/server.rb', line 32 def initialize( = {}) @options = @@default_options.merge() end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/icinga/server.rb', line 5 def @options end |
Instance Method Details
#connection ⇒ Object
14 15 16 |
# File 'lib/icinga/server.rb', line 14 def connection @conn ||= Net::HTTP.new(@options[:host], @options[:port]) end |
#hosts ⇒ Object
24 25 26 |
# File 'lib/icinga/server.rb', line 24 def hosts Responder.new(self, new_request("?hostgroup=all&style=hostdetail")) end |
#new_request(path) ⇒ Object
18 19 20 21 22 |
# File 'lib/icinga/server.rb', line 18 def new_request(path) req = Net::HTTP::Get.new(@options[:remote_path] + path + "&" + @options[:format] + "output") req.basic_auth @options[:user], @options[:password] if @options[:user] req end |