ruby-icinga2
Ruby Class for the Icinga2 API
Requirements
- ruby version ~> 2.3
- rest-client ~> 2.0
- openssl ~> 2.0
- json ~> 2.1
install
gem install icinga2
usage
create an instance
config = {
:icinga => {
:host => icingaHost,
:api => {
:port => icingaApiPort,
:user => icingaApiUser,
:pass => icingaApiPass
},
:cluster => icingaCluster,
:satellite => icingaSatellite,
}
}
@icinga = Icinga::Client.new( config )
Status
supports the following API Calls:
-
- add service (this function is not operable yet!)
- delete service (not yet implemented)
- add service (this function is not operable yet!)
- list unhandled services (not yet implemented)
- list services
- check if service exists
- list service objects
- adjusted service state
- count services with problems
- list of services with problems
- update host (this function is not operable yet!)
- count of all services
- count all services with handled problems
- calculate service severity (protected)
-
- enable host notifications
- disable host notifications
- enable service notifications
- disable service notifications
- enable hostgroup notifications
- disable hostgroup notifications
- list all notifications
- host notification (protected)
- hostgroup notification (protected)
- service notification (protected)
create a own gem File
#$ gem build icinga2.gemspec
Successfully built RubyGem
Name: icinga2
Version: 0.6.0
File: icinga2-0.6.0.gem
install gem
#$ gem install icinga2
Successfully installed icinga2-0.6.0
1 gem installed
test via CLI
#$ irb
2.3.0 :001 > require 'icinga2'
=> true
2.3.0 :002 > config = { :icinga => { :host => 'localhost', :api => { :user => 'root', :pass => 'icinga' } } }
=> {:icinga=>{:host=>"localhost", :api=>{:user=>"root", :pass=>"icinga"}}}
2.3.0 :003 > i = Icinga2::Client.new( config )
test via example
#$ export ICINGA_HOST=localhost ; export ICINGA_API_USER=root ; export ICINGA_API_PASSWORD=icinga
#$ ruby examples/test.rb
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request