IcingaApi

This is an still experimental gem to access the Icinga Web REST API. Use with caution, due to it's early development state.

Installation

Add this line to your application's Gemfile:

gem 'icinga_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install icinga_api

Usage

simple expamples

create connection

require 'icinga_api'

icinga = IcingaApi.new(
  url: "http://icinga-server/icinga-web",
  authkey: "myauthkey"
)

host API

host = icinga.host("my-monitored-host")

# is the host up?
up = host.up?

# what is the state of the host?
state = host.current_state

# when was the last check of the host
t = host.last_check

# has the host problem been acknowledged?
ack = host.problem_has_been_acknowledged

# get a list of services of the host
services = host.services

# get a specific service by name on a host
service = host.service("Time")

etc.

service API

# is the service ok?
is_ok = service.ok?

# since when is the service in the current state?
t = service.last_state_change

# what is the display name of the service?
str = service.display_name

# when will the service be checked the next time?
t = service.next_check

etc.

more advanced examples

IcingaApi understands predefined or manual filters, which make it possible to query any parameters

host api

# find all hosts which are down
hosts = icinga.hosts(IcingaApi::Host::F_DOWN)

# find all hosts which are down and not acknowledged the easy_way
hosts = icinga.hosts_down

# or with filters:
hosts = icinga.hosts(IcingaApi::Host::F_DOWN & IcingaApi::Host::F_NACK)

# or with manually defined filters:
filter_host_down = IcingaApi::Filter.new('HOST_CURRENT_STATE', '=', 1)
filter_host_not_ack = IcingaApi::Filter.new('HOST_PROBLEM_HAS_BEEN_ACKNOWLEDGET', '=', 0)
hosts = icinga.hosts(filter_host_down & filter_host_not_ack)

Contributing

  1. Fork it ( https://github.com/terracor/icinga_api/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request