assign define hosts to specific users

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
baber
Posts: 308
Joined: Wed Oct 21, 2015 4:39 am

Re: assign define hosts to specific users

Post by baber »

dwhitfield wrote:For clarity, the anchor tag should have taken you directly to the contact section of the document.

Here is a contact example:

Code: Select all

define contact{
	contact_name	contact_name
	minimum_value	0
	host_notifications_enabled	[0/1]
	service_notifications_enabled	[0/1]
	host_notification_period	timeperiod_name
	service_notification_period	timeperiod_name
	host_notification_options	[d,u,r,f,s,n]
	service_notification_options	[w,u,c,r,f,s,n]
	host_notification_commands	command_name
	service_notification_commands	command_name
}
Please let us know if you need additional examples.

Can you show the output of ls -la /usr/local/nagios/etc?

Code: Select all

drwxrwxr-x. 8 nagios nagios  4096 Dec 12 23:22 .
drwxr-xr-x. 9 nagios nagios  4096 May 26  2016 ..
drwxr-xr-x. 2 root   root    4096 Aug  2 22:41 backup
-rw-rw-r--. 1 nagios nagios 12374 Dec 12 22:16 cgi.cfg
-rw-rw-r--. 1 nagios nagios 12267 May 26  2016 cgi.cfg~
drwxr-xr-x. 2 root   root    4096 Dec  8 17:38 Esxi
-rw-r--r--. 1 root   root      64 Dec 12 22:01 htpasswd.users
drwxr-xr-x. 2 root   root    4096 Dec  8 23:02 linux
drwxr-xr-x. 2 root   root    4096 Dec  5 17:46 MSA
-rw-r--r--. 1 root   root   51525 Dec 12 21:52 nagios.cfg
-rw-rw-r--. 1 nagios nagios 44831 May 26  2016 nagios.cfg~
-rw-r--r--. 1 nagios nagios  8860 Sep 22 16:47 nrpe.cfg
drwxrwxr-x. 2 nagios nagios  4096 Dec  5 20:04 objects
-rw-rw----. 1 nagios nagios  1343 Aug 10 01:40 resource.cfg
-rw-rw----. 1 nagios nagios  1312 May 26  2016 resource.cfg~
drwxr-xr-x. 2 root   root    4096 Dec 12 23:22 windows

Also, can you post your nagios.cfg and contacts.cfg?

Code: Select all

i have attached contact.cfg file
Attachments
contacts.cfg
(2.65 KiB) Downloaded 609 times
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: assign define hosts to specific users

Post by dwhitfield »

Your contacts.cfg is in another directory, but I can't tell where it should be because you didn't upload your nagios.cfg. If you'd prefer to PM it, that will work. Just make sure you update this thread after you PM it.

UPDATE: nagios.cfg received and shared with techs
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: assign define hosts to specific users

Post by ssax »

Multi-tenancy is the key, please read this document:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

See here as well:

https://assets.nagios.com/downloads/nag ... Rights.pdf

Code: Select all

Note:

If you apply a contact/contactgroup to the host they will automatically be able to view all services attached to that host, this is by design, if you do not want a user to see all services you will only be able to add the contact/contactgroups on the services and NOT on the host.
Let us know if you have any questions.


Thank you
baber
Posts: 308
Joined: Wed Oct 21, 2015 4:39 am

Re: assign define hosts to specific users

Post by baber »

dwhitfield wrote:Your contacts.cfg is in another directory, but I can't tell where it should be because you didn't upload your nagios.cfg. If you'd prefer to PM it, that will work. Just make sure you update this thread after you PM it.

UPDATE: nagios.cfg received and shared with techs

i have sent PM and attach nagios.cfg
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: assign define hosts to specific users

Post by dwhitfield »

What's the output of ls -la /usr/local/nagios/etc/objects? Looks like your contacts.cfg should be in there.

Also, did you read through the documentation @ssax sent?
baber
Posts: 308
Joined: Wed Oct 21, 2015 4:39 am

Re: assign define hosts to specific users

Post by baber »

dwhitfield wrote:What's the output of ls -la /usr/local/nagios/etc/objects? Looks like your contacts.cfg should be in there.

Also, did you read through the documentation @ssax sent?

i know my contact.cfg file is that

Code: Select all

drwxrwxr-x. 2 nagios nagios  4096 Dec  5 20:04 .
drwxrwxr-x. 8 nagios nagios  4096 Dec 12 23:22 ..
-rw-rw-r--. 1 nagios nagios 10862 Dec  5 22:03 commands.cfg
-rw-rw-r--. 1 nagios nagios  7688 May 26  2016 commands.cfg~
-rw-rw-r--. 1 nagios nagios  2711 Dec 13 00:11 contacts.cfg
-rw-rw-r--. 1 nagios nagios  2138 May 26  2016 contacts.cfg~
-rw-r--r--. 1 root   root     972 Dec 12 23:22 hostgroup.cfg
-rw-rw-r--. 1 nagios nagios  5375 May 26  2016 localhost.cfg
-rw-rw-r--. 1 nagios nagios  5375 May 26  2016 localhost.cfg~
-rw-rw-r--. 1 nagios nagios  3096 May 26  2016 printer.cfg
-rw-rw-r--. 1 nagios nagios  3096 May 26  2016 printer.cfg~
-rw-rw-r--. 1 nagios nagios  3265 May 26  2016 switch.cfg
-rw-rw-r--. 1 nagios nagios  3265 May 26  2016 switch.cfg~
-rw-rw-r--. 1 nagios nagios 20903 Dec 13 00:05 templates.cfg
-rw-rw-r--. 1 nagios nagios 10621 May 26  2016 templates.cfg~
-rw-rw-r--. 1 nagios nagios  3180 May 26  2016 timeperiods.cfg
-rw-rw-r--. 1 nagios nagios  3180 May 26  2016 timeperiods.cfg~
-rw-rw-r--. 1 nagios nagios  3991 May 26  2016 windows.cfg
-rw-rw-r--. 1 nagios nagios  3991 May 26  2016 windows.cfg~


but i don't know what do i have to add in contact.cfg file and what do i have to add in other files for that babak can see specific host or service
please write an example


and i want babak just see this host

Code: Select all

define host{
	use		windows-server			; Inherit default values from a template
	host_name	DB-Asisstant				; The name we're giving to this host
	alias		server DB-Asisstant			; A longer name associated with the host
	address		10.10.10.10			; IP address of the host
	}


define service{
	use					local-service
	host_name				DB-Asisstant
	service_description			Memory Usage
	check_command				check_nt!MEMUSE!-w 90 -c 95
	}

define service{
	use					local-service
	host_name				DB-Asisstant
	service_description			SqlServer
	check_command				check_nt!SERVICESTATE!-d SHOWALL -l MSSQLSERVER

	}

define service{
	use					local-service
	host_name				DB-Asisstant
	service_description			Cpu Usage
	check_command				check_nrpe!alias_cpu
	}

define service{
	use					local-service
	host_name				DB-Asisstant
	service_description			Disk Space
	check_command				check_nrpe!alias_volumes
	}

define service{
	use					local-service
	host_name				DB-Asisstant
	service_description			Time
	check_command				check_nrpe!check_windows_time
}
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: assign define hosts to specific users

Post by ssax »

baber, even though the links I posted were for XI they are still very relevant to Nagios Core, did you read through them (at least the multi-tenancy one)?
baber
Posts: 308
Joined: Wed Oct 21, 2015 4:39 am

Re: assign define hosts to specific users

Post by baber »

ssax wrote:baber, even though the links I posted were for XI they are still very relevant to Nagios Core, did you read through them (at least the multi-tenancy one)?
Yes i read that but previously said confused i have been paste all configs on previous post now please help me
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: assign define hosts to specific users

Post by rkennedy »

dwhitfield wrote:For clarity, the anchor tag should have taken you directly to the contact section of the document.

Here is a contact example:

Code: Select all

define contact{
	contact_name	contact_name
	minimum_value	0
	host_notifications_enabled	[0/1]
	service_notifications_enabled	[0/1]
	host_notification_period	timeperiod_name
	service_notification_period	timeperiod_name
	host_notification_options	[d,u,r,f,s,n]
	service_notification_options	[w,u,c,r,f,s,n]
	host_notification_commands	command_name
	service_notification_commands	command_name
}
Please let us know if you need additional examples.

Can you show the output of ls -la /usr/local/nagios/etc?

Also, can you post your nagios.cfg and contacts.cfg?
Your answer can be found above, and also in the documentation @ssax linked. What specifically are you having issues with?
Former Nagios Employee
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: assign define hosts to specific users

Post by tmcdonald »

baber wrote:Yes i read that but previously said confused
Have you seen the documentation on how a host is defined?

https://assets.nagios.com/downloads/nag ... .html#host

You will need to add the contact name to the contacts field in your host definition if you want the contact to be able to see that host.
Former Nagios employee
Locked