contact object required fields

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.
Locked
ikrabbe
Posts: 4
Joined: Sun Oct 19, 2014 4:29 am

contact object required fields

Post by ikrabbe »

Hey Nagios Community,

I'm very new to nagios, but a quite experienced unix admin.

Possibly there is an issue in the documentation, that I use to consult, when using new software. (Things that aren't understood, when reading the manual often lead to errors in the use of software.)

http://nagios.sourceforge.net/docs/nagi ... ml#contact

The definition of a contact says, that fields in red are required, which are

Code: Select all

contact_name
host_notifications_enabled
service_notifications_enabled
host_notification_period
service_notification_period
host_notification_options
service_notification_options
host_notification_commands
service_notification_commands
But the examplary

Code: Select all

objects/contact.cfg
reads

Code: Select all

define contact {
  contact_name     nagiosadmin
  use              generic-contact
  alias            Nagios Admin
  contactgroups  admins
  email           none-of-your-business
}
define contactgroup{
  contactgroup_name   admins
  alias               Nagios Administrators
  members             nagiosadmin
}
while the used contact template reads

Code: Select all

        name                            generic-contact         ; The name of this contact template
        service_notification_period     24x7                    ; service notifications can be sent anytime
        host_notification_period        24x7                    ; host notifications can be sent anytime
        service_notification_options    w,u,c,r,f,s             ; send notifications for all service states, flapping events, and scheduled downtime events
        host_notification_options       d,u,r,f,s               ; send notifications for all host states, flapping events, and scheduled downtime events
        service_notification_commands   notify-service-by-email ; send service notifications via email
        host_notification_commands      notify-host-by-email    ; send host notifications via email
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
  
Adding both, I miss the required fields

Code: Select all

host_notifications_enabled
service_notifications_enabled
I assume, the "required field" definition is wrong and both values default to 1?

Am I right or am I right?

regards,

ikrabbe
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: contact object required fields

Post by slansing »

The example on the documentation you linked does show using those two fields. Are you talking about an example that was installed with core? If so, it's quite possible that those lines are intentionally missing, requiring you to finish the set up of a contact (this would effectively stop you from receiving notification spam if you are new to Core, without setting the contacts up properly.)

What version of core are you on, and how was it installed? On what distro?
ikrabbe
Posts: 4
Joined: Sun Oct 19, 2014 4:29 am

Re: contact object required fields

Post by ikrabbe »

That's true, I'm talking about the sample-config files, that get installed as the initial configuration, when you install nagioscore from source.

I used the current github sourcecode at branch origin/master and compiled, installed and started that on a gentoo host.

The funny thing is, that the contact configuration, which I extended meanwhile by some more contact objects, seems to work perfectly without those "required" fields.

EDIT: I just activated some notifications about some error that has been detected on localhost http (a 403) and though the e-mail processing hasn't been successful due to some missing command chain, the notification command has been executed for all contacts I added. So I finally assume that those fields are not required and default to "1".
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: contact object required fields

Post by slansing »

Hmm, that will take some looking into, thank you for bringing this up though! Let us know if you experience any issues with these contacts without those definitions in place.
ikrabbe
Posts: 4
Joined: Sun Oct 19, 2014 4:29 am

Re: contact object required fields

Post by ikrabbe »

When it comes to "looking into", it might help that a new contact is created in code here

nagioscore/xdata/xodtemplate.c:971,980

Code: Select all

		case XODTEMPLATE_CONTACT:
			xod_begin_def(contact);

			new_contact->minimum_value = 0;
			new_contact->host_notifications_enabled = TRUE;
			new_contact->service_notifications_enabled = TRUE;
			new_contact->can_submit_commands = TRUE;
			new_contact->retain_status_information = TRUE;
			new_contact->retain_nonstatus_information = TRUE;
			break;
so it is as I observed: The variables notifications enabled variables default to TRUE. I did not found a required field mechanism yet. But this topic starts to address developers now.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: contact object required fields

Post by abrist »

Actually, this is probably a documentation issue as those fields do have a default in the source. Have you bumped into anything else, or should we just proceed with removing the *required* flags for those directives from the documentation?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ikrabbe
Posts: 4
Joined: Sun Oct 19, 2014 4:29 am

Re: contact object required fields

Post by ikrabbe »

Actually I just started to evaluate nagios for the companies needs, I work for.
If I detect more issues I will just report them here, or somewhere near.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: contact object required fields

Post by sreinhardt »

Sounds great! Bug fixes and issues are always welcome!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: contact object required fields

Post by eloyd »

ikrabbe wrote:Actually I just started to evaluate nagios for the companies needs, I work for.
If I detect more issues I will just report them here, or somewhere near.
If you're looking for more specific assistance, we would be happy to help you out.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
Locked