Class: IcingaApi

Inherits:
Object
  • Object
show all
Defined in:
lib/icinga_api.rb,
lib/icinga_api/host.rb,
lib/icinga_api/filter.rb,
lib/icinga_api/request.rb,
lib/icinga_api/service.rb,
lib/icinga_api/version.rb,
lib/icinga_api/host_group.rb

Defined Under Namespace

Classes: Filter, Host, HostGroup, Request, Service

Constant Summary collapse

VERSION =
"0.0.4"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ IcingaApi

Returns a new instance of IcingaApi.



17
18
19
# File 'lib/icinga_api.rb', line 17

def initialize(options = {})
  @data = options
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



15
16
17
# File 'lib/icinga_api.rb', line 15

def data
  @data
end

Instance Method Details

#host(name) ⇒ Object



22
23
24
# File 'lib/icinga_api.rb', line 22

def host(name)
  Host.new(self, name)
end

#host_group(name) ⇒ Object



40
41
42
# File 'lib/icinga_api.rb', line 40

def host_group(name)
  HostGroup.new(self, name)
end

#host_groups(filter) ⇒ Object



45
46
47
# File 'lib/icinga_api.rb', line 45

def host_groups(filter)
  # TODO
end

#hosts(filter = nil) ⇒ Object



27
28
29
30
31
32
# File 'lib/icinga_api.rb', line 27

def hosts(filter=nil)
  rc = Request::request(self, Host::TARGET, filter, [:HOST_NAME])
  rc[:result].map do |host_hash|
    Host.new(self, host_hash[:HOST_NAME])
  end
end

#hosts_up(filter = nil) ⇒ Object



35
36
37
# File 'lib/icinga_api.rb', line 35

def hosts_up(filter=nil)
  hosts(filter ? (Host::F_UP & filter) : Host::F_UP)
end