Page 1 of 1
Cloning from template hosts with services
Posted: Tue Apr 19, 2016 7:15 pm
by akelsoe.seterus
So we have template hosts with all the template services and configs. We have one such template host for each of several different service classifications. Since these are static templates rather than real hosts, they aren't tied to an actual IP. If they were set active they would all permanently show critical. I'd like to have that template host inactive, but used as a basis for bulk host import/clone. It looks like this isn't possible since the bulk host import/clone wizard uses the nagios database which doesnt contain inactive configs.
Is there a way to completely hide a template host from the web interface if I set the templates as active? More preferably, is there a way to use these inactive templates as sources to clone new machines from?
Re: Cloning from template hosts with services
Posted: Wed Apr 20, 2016 9:36 am
by lmiltchev
Is there a way to completely hide a template host from the web interface if I set the templates as active? More preferably, is there a way to use these inactive templates as sources to clone new machines from?
I don't believe this is possible, however you could probably use the REST API to add hosts, using a template of your choice. For example, you could create a simple bash script like the one below:
Code: Select all
#!/bin/bash
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/host?apikey=l3i0i3np&pretty=1" -d "host_name=1.1.1.1&address=1.1.1.1&use=mytemplate&force=1"
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/host?apikey=l3i0i3np&pretty=1" -d "host_name=2.2.2.2&address=2.2.2.2&use=mytemplate&force=1"
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/host?apikey=l3i0i3np&pretty=1" -d "host_name=3.3.3.3&address=3.3.3.3&use=mytemplate&force=1&applyconfig=1"
To learn more about the REST API, from the Nagios XI web inteface click on the "Help" menu.
You can also go another route, where you can automate host management via custom scripts. Read more about the automated host management in XI here:
https://assets.nagios.com/downloads/nag ... gement.pdf
Hope this helps.
Re: Cloning from template hosts with services
Posted: Thu Apr 21, 2016 1:05 pm
by gormank
Not sure if it would be visible to the bulk tool, but you might try putting the files in the static dir...
Re: Cloning from template hosts with services
Posted: Thu Apr 21, 2016 2:14 pm
by lmiltchev
Not sure if it would be visible to the bulk tool, but you might try putting the files in the static dir...
A template, copied to the static won't be visible in the web UI, and won't be in the "Bulk Host Cloning and Import" wizard drop-down menu.
If you set it up as a "regular" host, then it will be available in the Bulk Host, and will be visible in the GUI.