Massively change hostname objects

Hi.
On my system, I need to change, massively, hostname from fqdn to hostname without domain suffix.
i.e.
machine1.local.domain
machine2.local.domain
.
.

to
machine1
machine2
.
.

How could I execute this massively?
So, I need to change: “object_name”

Could I use api director with POST or PUT method?

Thanks a lot.
Mario

  • Director version (System - About): 1.11.1
  • Icinga Web 2 version and modules (System - About):2.12.1
  • Icinga 2 version (icinga2 --version):r2.14.2-1
  • Operating System and version:Ubuntu 20.04.6 LTS
  • Webserver, PHP versions: Apache/2.4.41, PHP 7.4.3

Maybe doing this directly in the director DB would be a valid strategy.
Take a backup before and give it a try.

1 Like

Thanks
I solved with

UPDATE icinga_host SET object_name = REPLACE(object_name, '.local.domain', '') FROM icinga_host_inheritance WHERE (icinga_host_inheritance.parent_host_id = 6) AND (icinga_host.object_name like '%local.domain%')

In my case, I added the inner join with icinga_host_inheritance because my hosts has the import template like icinga_host_inheritance.parent_host_id = 6

1 Like

There is a problem with “Business Process Module”
If I rename host.name, from:
machine1.local.domain to machine1

the business process containing the machine1.local.domain become orphan
It isn’t linked anymore with the renamed host

How could I solve?

Thanks

This is not linked.
you can iterate over the files and replace this in:
/etc/icingaweb2/modules/businessprocess/processes

1 Like