Hostgroups for specific users
Hostgroups for specific users
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
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
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:
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.
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-*
}
Nicholas Scott
Former Nagios employee
Former Nagios employee
Re: Hostgroups for specific users
Thanks for your response nscott.
I have created a couple of host templates:
and the host definition is
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
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
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
}Code: Select all
define host {
host_name server-x
use data-hosts,xiwizard_windowsserver_host
........
}
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
........
}
Is there a way to fix this? I would appreciate if you could please take this request as urgent.
Thanks
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Hostgroups for specific users
You need to click the + under the contact box (through the XI interface) which is for additive inheritance.
This should make them look like
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
Thanks for the swift response scottwilkerson.
This is exactly how my hosttemplates.cfg file looks like (just like you suggested)
But the same problem persists. server-x has
and server-y has
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
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
}
Code: Select all
use data-hosts,xiwizard_windowsserver_hostCode: Select all
use xiwizard_windowsserver_host,data-hostsIs there something I am missing? Please take this as an urgent request.
Thanks
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Hostgroups for specific users
Lets check to see that the + is selected on server-x & server-y hosts as well
Re: Hostgroups for specific users
Did you mean:
if yes then it would give an error.
Any other suggestions, please?
Code: Select all
use +xiwizard_windowsserver_host,+data-hostsAny other suggestions, please?
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Hostgroups for specific users
No, I meant server-x and server-y should haveTSCAdmin wrote:Did you mean:
if yes then it would give an error.Code: Select all
use +xiwizard_windowsserver_host,+data-hosts
Any other suggestions, please?
Code: Select all
use +xiwizard_windowsserver_host,data-hostsRe: Hostgroups for specific users
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:
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
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!
Nagios Core UI -> left menu -> Configuration -> Hosts -> Update
Thanks
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Hostgroups for specific users
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 hostsTSCAdmin 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.
You do not have the required permissions to view the files attached to this post.