Ruby API

An enhanced Ruby gem to communicate with Icinga2 API


An enhanced ruby gem to communicate with Icinga2 API

Gem Version

Build Status Gem Downloads total Downloads Dependency Status


  • ruby version => 2.0
  • rest-client ~> 2.0
  • json ~> 2.1
  • openssl ~> 2.0 (only with ruby >= 2.3)
  • ruby_dig (only with ruby < 2.3)


gem install icinga2


create an instance

require 'icinga2'

config = {
  icinga: {
    host: icinga_host,
    api: {
      port: icinga_api_port,
      username: icinga_api_user,
      password: icinga_api_pass

@icinga = config )

Use the examples

You can use the Icinga Vagrant-Box from the Icinga Team or my own Docker Container as Datasource.

Remember Change the exported Environment Variables to your choosed Datasource!

you can find many examples under the directory examples:

$ export ICINGA_HOST=localhost ; export ICINGA_API_USER=root ; export ICINGA_API_PASSWORD=icinga
$ ruby examples/informations.rb
$ ruby examples/statistics.rb
$ ruby examples/users.rb

and so on.

Test via CLI

$ irb
irb(main):001:0&gt; require 'icinga2'
 =&gt; true
irb(main):002:0&gt; config = { icinga: { host: 'localhost', api: { username: 'root', password: 'icinga' } } }
 =&gt; {:icinga=&gt;{:host=&gt;"localhost", :api=&gt;{:username=&gt;"root", :password=&gt;"icinga"}}}
irb(main):003:0&gt; i = config )
irb(main):004:0&gt; i.available?
=&gt; true

Create a own gem file

$ gem build icinga2.gemspec
Successfully built RubyGem
Name: icinga2
File: icinga2-

Install local gem

$ gem install icinga2
Successfully installed icinga2-
1 gem installed


supports the following API Calls: