Re: [Nagios-devel] [PATCH] Fix default value for

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
Guest

Re: [Nagios-devel] [PATCH] Fix default value for

Post by Guest »

On 01/14/2013 10:30 AM, Ton Voon wrote:
>
> On 11 Jan 2013, at 17:08, Andreas Ericsson wrote:
>
>> On 01/11/2013 02:43 PM, Ton Voon wrote:
>>> 2) an env_macros field is available in all objects to
>>> define specifically which environment macros. This is a comma
>>> separated list, defaulting to ALL for backwards compatibility
>>>
>>
>> I was thinking more along the lines of
>>
>> define command {
>> env ORACLE_HOME=/foo/bar/lala
>> env HOST_NAME=$HOSTNAME$
>> command_name check_something
>> command_line /path/to/some-check
>> }
>>
>> since that also lets users set variables that aren't exactly Nagios related.
>
> I think that's a great idea and better than my proposal.
>
> Conceptually, the environment macros are based on plugin/notification/eventhandlers/perfhandler requirements, so putting this in a "define command" is more accurate than in "define service".
>
>
>>
>>> I'm happy to do some of this work, but will require agreement on the
>>> design and some technical assistance.
>>>
>>
>> If you get the macros to the workers as kvvec key/value pairs like this:
>>
>> k=env
>> v=NAGIOS_(MACRO_NAME)=macro value
>>
>> then I'll make sure the workers set up the environment properly. I'll
>> make an addendum to the worker rules though so the (possibly huge)
>> macro values don't have to be passed back to Nagios for every check
>> executed.
>
> Please find a patch that is setting the envvars. This sets before execution and then unsets at the end. I've only done it for 4 hard coded variables - it should be based on this new env property. It's clearly not production ready yet.
>
> Are there any kv limits to be aware of?
>

Nope. The key value vectors will expand as necessary, although you
have to use kvvec_destroy() with the proper flags to get rid of the
memory they're using (which is being done for the coreworker
communication already, so nothing to worry about there).

> What I can't work out is how to set the env property in "define command". Can you provide some pointers and assistance?
>

Using a secondary list of key/value vectors. Since commands are usually
fewer than 500 and remain pretty static, I'd just use a command->id
indexed pointer-to-pointer list of key value vectors.

--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: ae@op5.se
Locked