Page 1 of 1

Changing configuration directives for huge services list

Posted: Tue Mar 08, 2011 5:32 am
by TSCAdmin
Hello again,

We are using Nagios XI 2009R1.3 and monitoring over 5000 services. We have used configuration wizards to add new hosts. The configurations looks like the following:

Code: Select all

define service {
        host_name                       hostxyz.example.com
        service_description             Disk Monitor
        use                             xiwizard_windowsserver_disk_service
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        notification_interval           60
        contacts                        nagiosadmin,servicenow
        _xiwizard                       dh_windows_server
        register                        1
        }
Now it is being decided to change check_interval from 5 to 60 minutes. Is there an easy to way to change this directive for all 5000 services?

--------------------

It seems the wizard doesn't honour the directives in the templates. The template xiwizard_windowsserver_disk_service has check_interval set to 60 but when I add disk monitor service to any host it will have the same configuration as above.

The snippet below is from php file which has code for dealing with disk checks

Code: Select all

case "disk":
	$objs[]=array(
		"type" => OBJECTTYPE_SERVICE,
		"host_name" => $hostname,
		"service_description" => "Disk Monitor",
		"use" => "xiwizard_linuxserver_disk_service",
		"_xiwizard" => $wizard_name,
	);

break;
Is that a bug (feature)? Any help is appreciated. Thanks

Re: Changing configuration directives for huge services list

Posted: Tue Mar 08, 2011 11:22 am
by mguthrie
If the check_interval is specified in all 5000 services, then that setting will override the template. I think you're correct in that the wizard specifies the 5mn check_interval for each service, and for your particular situation it's better to have this as a template setting. Normally I'd say this part of the wizard is a 'feature', but for your situation it's working against you.

If that's the case, then for a mass change like this you'll probably want to do an SQL query to change all of the selected services that you want. If you want I can see if we can come up with a statement that will work for you, or if you know any SQL guru's they can probably do this in about 2 minutes. Here's the DB info you'd need.

In MySQL -> Database: nagiosxi -> Table: tbl_service -> Field: check_interval

If you guys end up coming up with the query for this, go ahead and post it, we might try and make a script tool for mass changes like this.

Re: Changing configuration directives for huge services list

Posted: Tue Mar 08, 2011 1:06 pm
by TSCAdmin
Brilliant input. I would love to give it a try but I have another question please.

I wrote a little query for this and tried changing the value for a single host, it seems to work but it's not reflected in the conf file on the disk. How do I sync them both?

Thanks

Re: Changing configuration directives for huge services list

Posted: Tue Mar 08, 2011 5:10 pm
by mguthrie
Once you change it in the database, all you'd have to do is either use the Write Config Tool, or Apply Configuration, and it should sync up the files.

Re: Changing configuration directives for huge services list

Posted: Wed Mar 09, 2011 6:04 am
by TSCAdmin
Wow, that really worked. All I had to do is:

Login to the mysql prompt

Code: Select all

mysql> use nagiosql;

mysql> update tbl_service set check_interval=60 where service_description='Disk Monitor';

mysql> select config_name, service_description, check_interval from tbl_service where service_description='Disk Monitor';
and then use Write Config tool to sync the changes to configuration files on disk.

I appreciate your support mguthrie. Cheers :)

Re: Changing configuration directives for huge services list

Posted: Wed Mar 09, 2011 10:42 am
by mguthrie
Awesome, glad that worked for you! Thanks for posting what you did as well, I tested it on my machine for a different change and it also worked like a charm. I posted the example to our wiki since there have been other situations where people needed to make a change like this.

http://support.nagios.com/wiki/index.ph ... In_The_CCM

Re: Changing configuration directives for huge services list

Posted: Thu Mar 10, 2011 9:44 am
by TSCAdmin
Thank you ever so much :)

Re: Changing configuration directives for huge services list

Posted: Thu Mar 10, 2011 10:25 am
by rdedon
Please feel free to contact us again if you require any additional assistance, we will be glad to help! :-)