Hello,
We are using icingaweb2 director for managing our icinga2 environment.
Beside sync jobs, manual editing, we are using the director api for a small subset of tasks we are already using the director api.
Now we have the following situation:
We have a lot of hosts with a lot of direct attached services.
Now we want to remove some (a lot) of these services.
using the script example “curlhelper” from icingaweb2 director api (https://icinga.com/docs/director/latest/doc/70-REST-API/)
with the following query i get the whole list of service objects:
./curlhelper.sh GET ‘director/services’
{ "objects": [ {
"check_period": "24x7",
"display_name": "check1",
"groups": [
"standard_nrpe_checks"
],
"host": "server1",
"imports": [
"svc_nrpe_check_generic"
],
"object_name": "check1",
"object_type": "object",
"vars": {
"nrpe_command": "cmd1",
"nrpe_timeout": "60"
}
}, {
"check_period": "24x7",
"display_name": "check2",
"groups": [
"standard_nrpe_checks"
],
"host": "server2",
"imports": [
"svc_nrpe_check_generic"
],
"object_name": "check2",
"object_type": "object",
"vars": {
"nrpe_command": "cmd2",
"nrpe_timeout": "60"
}
...
}] }
I’m looking for a query to get a list filtered by “object_name” and “host” or something else…
trying:
./curlhelper.sh GET ‘director/service?object_name=check1’
gives
{
"error": "Object is required"
}
When I try to use “name” instead of “object_name” I get the following answer:
./curlhelper.sh GET “director/service?name=check1”
{
"error": "Failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = 'check1' AND object_type = 'template'"
}
but I can’t give the “object_type=object” as additional parameter. It will not recognized:
./curlhelper.sh GET “director/service?name=check1&properties=all&object_type=object”
{
"error": "Failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = 'check1' AND object_type = 'template'"
}
I don’t know howto get the wanted list and I also don’t kow howto write the query to remove these kind of “direct attached” services.
Can someone lead me into the right direction, please?
I really don’t want to remove over 1000 services manually in director webinterface
Thank you and best regards
Thomas