Page 1 of 2
Hostgroups for specific users
Posted: Thu Jan 12, 2012 9:25 am
by TSCAdmin
Hello Nagios Support team,
We have got a bunch of hosts, let's say host-01 to host-10. They belong to a particular team team-x.
Now I want create a config so that when team-x logs with their account "user-x" they can see all these hosts only. I also want to create a hostgroup, hostgroup-x, for the reference of Nagios admins.
What would be the best way to achieve this without creating many templates and touching each host file?
Thanks
Re: Hostgroups for specific users
Posted: Thu Jan 12, 2012 1:11 pm
by nscott
TSCAdmin,
For the multitenancy its unfortunate but you will have to edit each host individually to add the proper contacts or templates (I would suggest the template route.)
As far as creating hostgroups thats a different story. I would certainly test this out in a non-production environment first, but this would be a quick way to do it:
Open up your /usr/local/nagios/etc/nagios.cfg (either in a terminal or using the Core Config Manager > Advanced > Nagios Core Main Config) and find the variable:
use_regexp_matching
And set it equal to zero. Now you'll have to add a manually configured hostgroup definition (as the Core Config Manager won't let you add hosts manually) so you'll need to add a config file to your /usr/local/nagios/etc/static folder as this folder does not get overwritten by the Core Config Manager. So make a new file in this folder and name it something like global_hostgroups.cfg and define the following:
Code: Select all
define hostgroup {
hostgroup_name group-2
members ^hostx-*
}
What this will do is put all hosts with the name that starts with hostx- and then ANYTHING else after that, and will put anything that matches that description into the hostgroup named group-2. I hope this makes sense.
Re: Hostgroups for specific users
Posted: Fri Jan 13, 2012 9:55 am
by TSCAdmin
Thanks for your response nscott.
I have created a couple of host templates:
Code: Select all
define host {
name data-hosts
contacts data_team,nagiosadmin,servicedesk
..........
register 0
}
define host {
name xiwizard_windowsserver_host
check_command check_xi_host_ping!3000.0!80%!5000.0!100%
contacts nagiosadmin,servicedesk,windows_team
.........
register 0
}
and the host definition is
Code: Select all
define host {
host_name server-x
use data-hosts,xiwizard_windowsserver_host
........
}
Now when I login as data team I could see the server "server-x" in Nagios XI but not when I login as windows_team
But when I change the use directive's order like
Code: Select all
define host {
host_name server-x
use xiwizard_windowsserver_host,data-hosts
........
}
i could see the server "server-x" in Nagios XI when I login as user "windows_team" but not when I login as "data_team".
Is there a way to fix this? I would appreciate if you could please take this request as urgent.
Thanks
Re: Hostgroups for specific users
Posted: Fri Jan 13, 2012 10:29 am
by scottwilkerson
You need to click the + under the contact box (through the XI interface) which is for additive inheritance.
This should make them look like
Code: Select all
define host {
name data-hosts
contacts +data_team,nagiosadmin,servicedesk
..........
register 0
}
define host {
name xiwizard_windowsserver_host
check_command check_xi_host_ping!3000.0!80%!5000.0!100%
contacts +nagiosadmin,servicedesk,windows_team
.........
register 0
}
Re: Hostgroups for specific users
Posted: Fri Jan 13, 2012 2:44 pm
by TSCAdmin
Thanks for the swift response scottwilkerson.
This is exactly how my hosttemplates.cfg file looks like (just like you suggested)
Code: Select all
define host {
name data-hosts
use xiwizard_generic_host
contacts +data_team,nagiosadmin,servicedesk
register 0
}
define host {
name xiwizard_windowsserver_host
check_command check_xi_host_ping!3000.0!80%!5000.0!100%
use xiwizard_generic_host
contacts +nagiosadmin,servicedesk,windows_team
register 0
}
But the same problem persists. server-x has
Code: Select all
use data-hosts,xiwizard_windowsserver_host
and server-y has
Code: Select all
use xiwizard_windowsserver_host,data-hosts
When I login as data_team, I could see server-x but not server-y. But when I login as windows_team I could see server-y but not server-x.
Is there something I am missing? Please take this as an urgent request.
Thanks
Re: Hostgroups for specific users
Posted: Fri Jan 13, 2012 4:08 pm
by scottwilkerson
Lets check to see that the + is selected on server-x & server-y hosts as well
Re: Hostgroups for specific users
Posted: Mon Jan 16, 2012 9:05 am
by TSCAdmin
Did you mean:
Code: Select all
use +xiwizard_windowsserver_host,+data-hosts
if yes then it would give an error.
Any other suggestions, please?
Re: Hostgroups for specific users
Posted: Mon Jan 16, 2012 9:46 am
by scottwilkerson
TSCAdmin wrote:Did you mean:
Code: Select all
use +xiwizard_windowsserver_host,+data-hosts
if yes then it would give an error.
Any other suggestions, please?
No, I meant server-x and server-y should have
Code: Select all
use +xiwizard_windowsserver_host,data-hosts
We made the contacts for the templates additive, but we need to make the contacts for the host additive.
Re: Hostgroups for specific users
Posted: Mon Jan 16, 2012 3:07 pm
by TSCAdmin
Could you please also explain how this can be achieved? There is no "+" option while inserting the templates in a host configuration in CCM. When I do this from command line and import the configuration file I get the following error:
Code: Select all
Error: Template '+xiwizard_windowsserver_host' specified in host definition could not be not found (config file '/usr/local/nagios/etc/hosts/us-ham-svv-0245.cfg', starting on line 14)
Error processing object config files!
Another question, is there a plugin/add-on for Nagios XI to expand and view the full configuration for a host in the GUI mode like we see in
Nagios Core UI -> left menu -> Configuration -> Hosts -> Update
Thanks
Re: Hostgroups for specific users
Posted: Mon Jan 16, 2012 3:39 pm
by scottwilkerson
TSCAdmin wrote:Could you please also explain how this can be achieved? There is no "+" option while inserting the templates in a host configuration in CCM.
I'm sorry, I said that wrong, what I meant was the + on the contacts. And you should do this for the templates and the hosts