Page 1 of 2

Mass change

Posted: Wed Nov 03, 2010 12:49 pm
by QS1
Is it possible to make a mass change to service checks or host checks with nagiosxi?
I know we were able to do this with centreon, but just wondering if an option is available.

Re: Mass change

Posted: Wed Nov 03, 2010 1:29 pm
by tonyyarusso
The proper way to do this is to make use of templates, and then change the template.

Re: Mass change

Posted: Fri Nov 05, 2010 11:58 am
by niebais
For our company, we use a setup involving a free program called "Selenium". We build a script in selenium that helps us do mass updates in case the template change isn't enough. Template changes are great for some things, but in my opinion, don't do very well when you have to change 300 alerts "Service Description" names.

Re: Mass change

Posted: Fri Nov 05, 2010 12:04 pm
by QS1
niebais wrote:For our company, we use a setup involving a free program called "Selenium". We build a script in selenium that helps us do mass updates in case the template change isn't enough. Template changes are great for some things, but in my opinion, don't do very well when you have to change 300 alerts "Service Description" names.
Thanks for the feedback... any links to this?
I see a few on google, just want to make sure I'm looking in the right area.

Re: Mass change

Posted: Fri Nov 05, 2010 3:26 pm
by niebais
http://seleniumhq.org/ - that's where you get the main program. Download the firefox browser plugin to get the recording started. Next install the server-remote control. The last step you just record what you want to do. I've got a basic perl framework created for that right now which works pretty well.

Re: Mass change

Posted: Fri Nov 05, 2010 4:23 pm
by niebais
It may seem really complicated at first, I guess, but it's the best tool I've found so far for mass updates, migrations, and creations.

Re: Mass change

Posted: Sat Nov 06, 2010 11:35 am
by mguthrie
That's a pretty cool resource to know about. Thanks for posting this!

Re: Mass change

Posted: Mon Nov 08, 2010 3:57 am
by tairline
I posted the same question in the standard support forums (under my own name).

I am very interested in this solution! Could you post some examples? The thing is that at this moment we deploy monitoring of all hosts on the basis of values changed in the XI configuration wizards.

But in the future it could be that these values are not sufficient (to many criticals, not enough criticals etc. etc.) So we are interested aswell in changing certain checks for a large number of hosts. For example: I want to change the value critical CPU load from 90 to 95% on all Linux machines.

So ermmm could you eleborate? Thank you in advance.

Re: Mass change

Posted: Mon Nov 08, 2010 12:48 pm
by mguthrie
For future hosts, I would recommend the use of templating through the Core Config Manager. Set up your service template (or several) with all of your desired settings defined, and you can then quickly add new services with these templates to your hosts. However, there is a dilemma if you want lower-level users to be doing these changes, as they generally don't have access to the Core Config Manager.

Re: Mass change

Posted: Tue Nov 09, 2010 1:32 pm
by niebais
I agree with the Nagios admins here, for this change I would probably be using a template or a command that I could easily change. However, for examples sake, here is a snippet of code from selenium, keep in mind it is in perl.

First I use a standard login to Nagios. I created a user that has full rights that I can automate things with (like automateruser)

Here is an example perl script for logging in:
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;

my $sel = Test::WWW::Selenium->new( host => "{SELENIUM_HOST}",
port => 4444,
browser => "*chrome",
browser_url => "{OPENING_URL_TO_NAGIOS_SYSTEM}" );

my $username = '{MY_NAGIOS_USER}';
my $password = '{PASSWORD}';
$sel->open_ok("/nagiosxi/login.php?redirect=/nagiosxi/index.php%3f");
login_to_nagios($username,$password);

#Next you run the commands you would like to run, here's how to change the critical assuming the cpu limit is listed on line ARG1
$sel->open_ok("/nagiosxi/config/nagioscorecfg/");
$sel->click_ok("link=Services");
$sel->wait_for_page_to_load_ok("30000");
$sel->type_ok("txtSearch", {MY_SERVICE_NAME});
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("//img[\@alt='Modify']");
$sel->wait_for_page_to_load_ok("30000");
$sel->type_ok("tfArg1", {NEW_CPU_VALUE});
$sel->click_ok("subForm1");
$sel->wait_for_page_to_load_ok("30000");


#keep in mind that the username, password combo MUST be the same as the original nagios login
sub login_to_nagios {
my $username = shift;
my $password = shift;
$sel->type_ok("usernameBox", $username);
$sel->type_ok("passwordBox", $password);
$sel->click_ok("loginButton");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("link=Configure");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("link=Core Config Manager");
$sel->wait_for_page_to_load_ok("30000");
$sel->type_ok("tfUsername", $username);
$sel->type_ok("tfPassword", $password);
$sel->click_ok("Submit");
$sel->wait_for_page_to_load_ok("30000");
}


Most of this is auto-generated by the IDE selenium downloaded from seleniumhq.org.