{"id":18513331,"url":"https://github.com/jbox-web/icinga2-api-client","last_synced_at":"2025-04-09T06:33:09.874Z","repository":{"id":146101287,"uuid":"104818957","full_name":"jbox-web/icinga2-api-client","owner":"jbox-web","description":"A Ruby gem to interact easily with the Icinga2 API ;)","archived":false,"fork":false,"pushed_at":"2024-10-24T16:56:27.000Z","size":92,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-25T23:57:04.180Z","etag":null,"topics":["client","icinga2","icinga2-api","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbox-web.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-26T01:12:23.000Z","updated_at":"2024-10-24T16:56:31.000Z","dependencies_parsed_at":"2023-10-03T02:59:22.311Z","dependency_job_id":"dd173649-0fdd-4222-8dc0-5e001177b0a5","html_url":"https://github.com/jbox-web/icinga2-api-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Ficinga2-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Ficinga2-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Ficinga2-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Ficinga2-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbox-web","download_url":"https://codeload.github.com/jbox-web/icinga2-api-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223367256,"owners_count":17134064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","icinga2","icinga2-api","ruby"],"created_at":"2024-11-06T15:37:39.110Z","updated_at":"2024-11-06T15:37:39.963Z","avatar_url":"https://github.com/jbox-web.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Icinga2 API Client\n\n[![GitHub license](https://img.shields.io/github/license/jbox-web/icinga2-api-client.svg)](https://github.com/jbox-web/icinga2-api-client/blob/master/LICENSE)\n[![CI](https://github.com/jbox-web/icinga2-api-client/workflows/CI/badge.svg)](https://github.com/jbox-web/icinga2-api-client/actions)\n[![Code Climate](https://codeclimate.com/github/jbox-web/icinga2-api-client/badges/gpa.svg)](https://codeclimate.com/github/jbox-web/icinga2-api-client)\n[![Test Coverage](https://codeclimate.com/github/jbox-web/icinga2-api-client/badges/coverage.svg)](https://codeclimate.com/github/jbox-web/icinga2-api-client/coverage)\n\nA Ruby gem to interact easily with the Icinga2 API.\n\nLargely copied (and adapted) from [gdi/ruby-nagios-api-client](https://github.com/gdi/ruby-nagios-api-client).\n\n## Install\n\n```sh\ngem install icinga2-api-client\n```\n\n## Usage\n\n```ruby\nrequire 'yaml'\nrequire 'icinga2/api'\n\nclient = Icinga2::API::Client.new('https://icinga.example.net:5665',\n  version: 'v1',\n  username: 'admin',\n  password: 'pass',\n  verify_ssl: false\n)\n\n# Get all hosts. It returns a list of Icinga2::API:Host objects\nputs YAML.dump client.hosts.all.map(\u0026:to_s)\n\n# Find host by name. It returns a Icinga2::API:Host object\nputs YAML.dump client.hosts.find('my.host.net').to_s\n\n# Get all services for host. It returns a list of Icinga2::API:Service objects\nputs YAML.dump client.hosts.find('my.host.net').services.all.map(\u0026:to_s)\n\n# Find service by name. It returns a Icinga2::API:Service object\nputs YAML.dump client.hosts.find('my.host.net').services.find('ssh').to_s\n\n# Create a schedule downtime\n# The duration param seems to be mandatory, even with 'fixed' param set to `true` (which is the default value).\nduration   = 1.hour\nstart_time = DateTime.now\nend_time   = start_time + duration\n\nssh_downtime =\n  client.hosts\n        .find('foo.example.net')\n        .services\n        .find('ssh')\n        .schedule_downtime(\n          author:     'admin',\n          comment:    'ok',\n          start_time: start_time.to_i, # Icinga wants timestamps so call to_i\n          end_time:   end_time.to_i,   # Icinga wants timestamps so call to_i\n          duration:   duration.to_i    # Icinga wants timestamps so call to_i\n        )\n\nhttp_downtime =\n  client.hosts\n        .find('foo.example.net')\n        .services\n        .find('http')\n        .schedule_downtime(\n          author:     'admin',\n          comment:    'ok',\n          start_time: start_time.to_i, # Icinga wants timestamps so call to_i\n          end_time:   end_time.to_i,   # Icinga wants timestamps so call to_i\n          duration:   duration.to_i    # Icinga wants timestamps so call to_i\n        )\n\n# Get all downtimes across all services. It returns a list of Icinga2::API:Downtime objects\nall_downtimes =\n  client.hosts\n        .find('foo.example.net')\n        .services\n        .downtimes\n\n# Get all downtimes for one service. It returns a list of Icinga2::API:Downtime objects\nall_ssh_downtimes =\n  client.hosts\n        .find('foo.example.net')\n        .services\n        .find('ssh')\n        .downtimes\n\nall_http_downtimes =\n  client.hosts\n        .find('foo.example.net')\n        .services\n        .find('http')\n        .downtimes\n\n# Cancel a downtime\nclient.hosts\n      .find('foo.example.net')\n      .services\n      .find('http')\n      .downtimes\n      .first\n      .cancel\n```\n\n## Contributors\n\nA big thank to [them](https://github.com/jbox-web/icinga2-api-client/graphs/contributors) for their contribution!\n\nAnd a big thank to [gdi/ruby-nagios-api-client](https://github.com/gdi/ruby-nagios-api-client) for the inspiration.\n\n## Contribute\n\nYou can contribute to this plugin in many ways such as :\n* Helping with documentation\n* Contributing code (features or bugfixes)\n* Reporting a bug\n* Submitting translations\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbox-web%2Ficinga2-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbox-web%2Ficinga2-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbox-web%2Ficinga2-api-client/lists"}