Delete Hosts

Hey,

I’m using the newest version of Icinga2, IcingaDB, IcingaRedis and Icinga Director.

Now my question:

What is the fastest way to delete all my hosts?

Best regards,
Philipp

1 Like

using icinga director api is definitely a fast way to delete all your hosts, but depending on how many are you have, there maybe is a simpler solution

I have around 300 test-hosts. I want to remove them all to test with the import-option around.

use the rest api and call:
GET director/hosts

I would suggest using python, because you will get a json in return.

from this json extract the object_name(s) and iterate over them calling
DELETE director/host?name=%%%%
and replace %%%% with the current hostname of your iteration

if you have the list of hostname present, you can also use a bash script with a for loop
and call for each line:
icingacli director host delete %%%%

1 Like

I found that in my documentation:
for i in $(icingacli director hosts list);do icingacli director host delete $i;done
Be careful with this command!!!

3 Likes

Perfect!

I think that will help.

I tried that but it also lists the hosttemplates so be careful