Bulk change service template

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cellact
Posts: 69
Joined: Mon May 14, 2012 7:00 am

Bulk change service template

Post by cellact »

Hi,
How can I bulk change service templates? (MySQL commands are good too)

Thanks.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Bulk change service template

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
cellact
Posts: 69
Joined: Mon May 14, 2012 7:00 am

Re: Bulk change service template

Post 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.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Bulk change service template

Post 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.
cellact
Posts: 69
Joined: Mon May 14, 2012 7:00 am

Re: Bulk change service template

Post 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?
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Bulk change service template

Post 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.
cellact
Posts: 69
Joined: Mon May 14, 2012 7:00 am

Re: Bulk change service template

Post by cellact »

So I can't run a MySQL command to apply templates to services? :cry:

Thanks
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk change service template

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
cellact
Posts: 69
Joined: Mon May 14, 2012 7:00 am

Re: Bulk change service template

Post by cellact »

I know, that's why I keep backups :D
Please share the command for applying templates over a service.

Thanks.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Bulk change service template

Post 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> );
Locked