Tying one attribute's value to another?

Support requests, bug reports, questions etc.
jsmegerman
NConf rookie
NConf rookie
Posts: 17
Joined: Tue Mar 12, 2013 18:50

Tying one attribute's value to another?

Post by jsmegerman » Fri May 24, 2013 21:04

I would like to have the name of the collector that monitors each host listed as an Icinga custom variable (e.g., _NCONF_monitoredby) in the config file. Adding the attribute is simple, but is there any way to have it automatically grab the value from the existing "monitored_by" attribute short of manually tweaking the database entry for the attribute after the fact so it pulls the same attribute value (which may not even work, I haven't tried it yet)? I'd rather have it be hidden in NConf and just write out to the .cfg files without having to specify any additional value...

Thanks,
Josh

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

Re: Tying one attribute's value to another?

Post by agargiulo » Fri May 31, 2013 08:53

Hi

Yes, there is a way to achieve this without tweaking the database.
Simply add your custom attribute and define it as data type "text".

Then edit your entry and add the following NConf macro as value: %NAGIOS_SERVER_NAME%

When the config is generated, the macro will be replaced with the name of the collector / monitor server in NConf.

For more info refer to:
http://www.nconf.org/dokuwiki/doku.php? ... tos:macros

jsmegerman
NConf rookie
NConf rookie
Posts: 17
Joined: Tue Mar 12, 2013 18:50

Re: Tying one attribute's value to another?

Post by jsmegerman » Mon Jun 03, 2013 20:33

Thanks for the response. Unfortunately, that's not actually going to do what I want, though if I wasn't trying to overload the icinga config for other purposes it would have been just fine. What I really want is to have the name of the collector in the config so that I can tell which collector host is monitoring each individual host when I parse the configs via other tools. Thus, a runtime macro won't provide the info I'm looking for, nor will pulling it from the livestatus plugin since it will be set to the central monitor hostname rather than the individual collector name. I may just have to create an attribute and then write a perl script that updates the attribute in the database whenever I run it. If you have any other ideas, I'd love to hear them, otherwise I'll figure something out.

Thanks,
Josh

ETA: re-reading the link I think I misinterpreted when it gets substituted, but it still looks like it puts in the name of the server for which the config is generated, rather than specifically the collector host (which is fine for the collectors, but not the monitor).

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

Re: Tying one attribute's value to another?

Post by agargiulo » Thu Jun 06, 2013 14:02

Yes, you're right. It puts The name of the server for which the config is generated.

What you're looking for would be something like a NAGIOS_COLLECTOR_NAME macro. This feature would have to be added.

Locked