Mass change

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
QS1
Posts: 195
Joined: Tue Sep 21, 2010 3:30 pm

Mass change

Post 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.
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Mass change

Post by tonyyarusso »

The proper way to do this is to make use of templates, and then change the template.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: Mass change

Post 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.
QS1
Posts: 195
Joined: Tue Sep 21, 2010 3:30 pm

Re: Mass change

Post 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.
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: Mass change

Post 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.
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: Mass change

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

Re: Mass change

Post by mguthrie »

That's a pretty cool resource to know about. Thanks for posting this!
tairline
Posts: 25
Joined: Mon Sep 20, 2010 2:33 am

Re: Mass change

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

Re: Mass change

Post 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.
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: Mass change

Post 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.
Last edited by niebais on Tue Nov 09, 2010 1:39 pm, edited 1 time in total.
Locked