Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #13025] Assign service to host with Director API #540

Closed
icinga-migration opened this issue Nov 1, 2016 · 2 comments
Closed

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/13025

Created by kelemen on 2016-11-01 15:29:46 +00:00

Assignee: (none)
Status: New
Target Version: (none)
Last Update: 2016-11-23 17:41:58 +00:00 (in Redmine)


Hello,

I wonder what is a proper way to assign a service to a host with Director API.

I was unable to find an example in the docs. Is there such an option at all?

Thanks!

@icinga-migration
Copy link
Author

Updated by birkir on 2016-11-23 17:41:58 +00:00

This worked for me for a basic service, but more options/arguments are available to put more detailed variables and such in the check:

curl -k -s -u USER:PASS -H 'Accept: application/json' -X PUT "http://icinga2.domain.com/icingaweb2/director/service?host=HOSTNAME&service=SERVICENAME" -d '{ imports [ "TEMPLATE" ], object_name "SERVICENAME", object_type "object", host "HOSTNAME"}'

Of course you should try to do it without the -k argument for curl, but for my testing purposes, i didn't care about it nor have the time to make https work for the curl request.
But yes, there appears to be no documentation for it, so i just figured this out myself from browser url's and good ol' trial-and-error.

and you can reload Director / Icinga2 for the service-check to go online with:
curl -k -s -u USER:PASS -H 'Accept: application/json' -X POST 'http://icinga2.domain.com/icingaweb2/director/config/deploy'

Edit: Nevermind, this is how to create a service for a host, not assign it to a host, sorry.

@Thomas-Gelf
Copy link
Contributor

The given example should work fine. In case more details are required please post a more specific question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants