Page 1 of 1

Bulk change service template

Posted: Wed Apr 03, 2013 9:50 am
by cellact
Hi,
How can I bulk change service templates? (MySQL commands are good too)

Thanks.

Re: Bulk change service template

Posted: Wed Apr 03, 2013 10:43 am
by abrist
The bulk modification tool only supports host and service objects. So an sql command may be the only way to bulk modify a template. What are you looking to alter?

Re: Bulk change service template

Posted: Thu Apr 04, 2013 2:38 am
by cellact
My configuration has about 1000 services which were created without a relevant template.
I'd like to start working with templates for those services.

I've already bulk-modified before using MySQL and have no problem running some queries.

Thanks.

Re: Bulk change service template

Posted: Thu Apr 04, 2013 11:16 am
by slansing
What are you looking to alter?
We need to know what specific changes you wish to make to the database as we can not support certain alterations due to the high possibility your database could be ruined. Are you looking to make changes to notification options for your templates, or something along those lines? I can only think of a few things you would wish to change as templates by design are singular configurations used to push that configuration to multiple hosts/services so identical templates would defeat the purpose in most cases.

Re: Bulk change service template

Posted: Wed Apr 10, 2013 6:04 am
by cellact
You've completely misunderstood me, but I guess it's my fault :)
I don't wish to change any templates, I'd just like to apply templates over a bulk of services.
Is this possible?

Re: Bulk change service template

Posted: Wed Apr 10, 2013 1:16 pm
by mguthrie
Did you utilize wizards at all for the creation of these services? If so, there would be a template assigned to those services automatically. If you want to add templates to existing services that currently don't utilize them, you'll have to manually add them at the moment. It's important to note that config directives in the service definitions will override any templates, but you can use the Bulk Modification tool to clear many of the values in a list of services. This will allow those services to inherit from the template.

See the following doc on more detailed info about object inheritance.
http://nagios.sourceforge.net/docs/3_0/ ... tance.html

You could also look at Service->hostgroup assignments if you have a lot of common services across your many hosts. This would allow you to manage one service definition for an entire group of hosts. You can also apply a single service definition to a list of hosts.

Re: Bulk change service template

Posted: Sun Apr 14, 2013 2:17 am
by cellact
So I can't run a MySQL command to apply templates to services? :cry:

Thanks

Re: Bulk change service template

Posted: Mon Apr 15, 2013 9:39 am
by lmiltchev
We don't recommend making changes directly in the database. Any issues on your Nagios XI server, caused by running MySQL commands this way would make your XI instance NOT supportable.

Re: Bulk change service template

Posted: Wed Apr 17, 2013 2:32 am
by cellact
I know, that's why I keep backups :D
Please share the command for applying templates over a service.

Thanks.

Re: Bulk change service template

Posted: Wed Apr 17, 2013 12:11 pm
by mguthrie
Again, this is most definitely a "Do this at your own risk!" scenario.

I'd suggest clearing all existing template relationships first for any affect services. These are starter queries, so you can decide how to best implement them.


foreach service:

Code: Select all

DELETE FROM `tbl_lnkServiceToServicetemplate` WHERE `idMaster`=<service_id>;
// <sort_order> should be 1 if you're only using 1 template on a service

Code: Select all

INSERT INTO `tbl_lnkServiceToServicetemplate` 
                (`idMaster`,`idSlave`,`idTable`,`idSort`)
    VALUES (<service_id>, <template_id>, 1 ,<sort_order> );