Class: Icinga::Client
- Inherits:
-
Object
- Object
- Icinga::Client
- Defined in:
- lib/icinga/client.rb
Overview
Client connection to Icinga server
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 = {}) ⇒ Client
constructor
A new instance of Client.
- #new_request(path) ⇒ Object
- #services(host = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
17 18 19 |
# File 'lib/icinga/client.rb', line 17 def initialize( = {}) @options = @@default_options.merge() end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/icinga/client.rb', line 7 def @options end |
Instance Method Details
#connection ⇒ Object
29 30 31 |
# File 'lib/icinga/client.rb', line 29 def connection @conn ||= Net::HTTP.new(@options[:host], @options[:port]) end |
#hosts ⇒ Object
21 22 23 |
# File 'lib/icinga/client.rb', line 21 def hosts Responder.create(Host, self, new_request("?hostgroup=all&style=hostdetail")) end |
#new_request(path) ⇒ Object
33 34 35 36 37 |
# File 'lib/icinga/client.rb', line 33 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 |