Custom Attributes

Support requests, bug reports, questions etc.
Locked
daemoen
beginner
beginner
Posts:8
Joined:Tue Jun 09, 2009 03:30
Custom Attributes

Post by daemoen » Tue Jun 09, 2009 03:35

I have added a few attributes, but NConf fails to be able to use them correctly.

IE: I have created: Host Attribue: extip External ip, mimics the settings for address, which the information needed changed (namely the name and description, order, etc).

Also created a new attribute for contacts:
Jabber

When I attempt to utilize the jabber attribute, configuration fails. I erase the data, it works again.

Here are the settings, and how I have utilized it.


Attribute ID: 101
Nagios-specific attribute name: jabber
Friendly name (shown in GUI): Jabber
description, example or help-text: GTalk Userid
Data type: text
max. text-field length (chars): 255
Possible values:
Predefined value:
Is attribute mandatory: no
Ordering position: 10
Is attribute visible: yes
write attribute to configuration: yes
naming attribute: no
link selected item(s) as children:
items of class to be assigned:
attribute belongs to class: contact


and I have a notify-host and notify-service by jabber definition, that links to jabber.pl in $USER1$ and calls $_CONTACTJABBER$. I have also tried $CONTACTJABBER$. Both fail.

Any suggestions on what is going wrong with custom attributes would assist. Im hoping that these are supposed to be the custom nagios variables that we are able to create, otherwise, how do we create custom variables / macros correctly?

User avatar
agargiulo
NConf developer
NConf developer
Posts:725
Joined:Fri Mar 06, 2009 17:50
Location:Zurich, Switzerland
Contact:

Re: Custom Attributes

Post by agargiulo » Tue Jun 09, 2009 09:48

Hi.

What NConf does is it allows you to add any custom attributes you like. These attributes will be written to your config files, just like any other attributes. For contacts, it would look like this:

Code: Select all

define contact {
                contact_name             nagiosadmin
                alias                    Nagios Admin
                email                    nagios@localhost
                jabber                   blabla
                ...
}

What you are doing is correct, but you have to make sure Nagios knows your custom attributes, otherwise you won't be able to start the daemon. I have tried adding the "jabber" attribute that you are describing. I get an error when I generate the config. The syntax check fails with the error:
Error: Invalid contact object directive 'jabber'. This is a message coming from the Nagios binary directly. It means that Nagios does not recognize the "jabber" attribute.

User avatar
agargiulo
NConf developer
NConf developer
Posts:725
Joined:Fri Mar 06, 2009 17:50
Location:Zurich, Switzerland
Contact:

Re: Custom Attributes

Post by agargiulo » Tue Jun 09, 2009 10:14

I believe I haven't answered your question correctly. It seems Nagios allows users to freely define custom attributes, under the following conditions:
- Custom variable names must begin with an underscore (_) to prevent name collision with standard variables
- Custom variable names are case-insensitive
- Custom variables are inherited from object templates like normal variables
- Scripts can reference custom variable values with macros and environment variables
In your case this would mean adding an attribute named "_jabber" to your contacts, an then referencing to it as a custom macro named $_CONTACTJABBER$.

At least that's how it is described in the Nagios documentation:
http://nagios.sourceforge.net/docs/3_0/ ... tvars.html
http://nagios.sourceforge.net/docs/3_0/macros.html --> see "Custom Variable Macros"

daemoen
beginner
beginner
Posts:8
Joined:Tue Jun 09, 2009 03:30

Re: Custom Attributes

Post by daemoen » Tue Jun 09, 2009 15:46

Nods, I am familiar with the nagios page on the macros. I wasn't sure what Nconf was doing though, as its handling of the attributes isnt documented. Thanks :) Ill test it now.

Ok. Works as expected now. I was not sure if NConf added the leading _ for you automatically or how it worked. Thanks for getting back to me on this and for the example of how NConf actually handles it.

Locked