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( = {}) = .merge() end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/icinga/client.rb', line 7 def end |
Instance Method Details
#connection ⇒ Object
29 30 31 |
# File 'lib/icinga/client.rb', line 29 def connection @conn ||= Net::HTTP.new([:host], [: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([:remote_path] + path + "&" + [:format] + "output") req.basic_auth [:user], [:password] if [:user] req end |
#services(host = nil) ⇒ Object
25 26 27 |
# File 'lib/icinga/client.rb', line 25 def services(host=nil) Responder.create(Service, self, new_request("?host=#{host.nil? ? "all" : host}&style=servicedetail")) end |