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/16/2013 11:24 AM, Ton Voon wrote:
> Hi Andreas,
>
> Please find attached a patch to support environment macros. I've amended it so that it uses the array method instead of the object method, so there is no structural change.
>
> Random things:
> * worker processes take the key/value information. I think I've got all the memory allocation/deallocation right, but I'd welcome a review of that

I'll take a look at it tomorrow. I'm on a bus right now so I'm short
some tools (well, patience really) for running it through valgrind
and such.

> * There's an assumption that putenv() is available

That's probably fine, but we can get around it without paying the
ridiculous performance penalty on Solaris as well, by using execvpe()
to spawn commands and passing a complete environment in the third
argument.

Without having looked closer, I can say it's likely I take this patch.
Any performance polish can be done later, and I'll make sure there are
no leaks.

> * I've added an example in sample-config with notes:
>

Excellent.

> # You can also define environment variables that will be passed to the command after expansion
> # Unknown/invalid macros will get converted to an empty string (eg, service macros for a host check)
> # This applies for checks, notifications, event handlers and performance handlers
> define command{
> command_name custom-notify-by-carrier-pigeon
> command_line $USER1$/notify-script
> env NAGIOS_SERVICESTATE=$SERVICESTATE$
> env NAGIOS_HOSTALIAS=$HOSTALIAS$
> env ORACLE_SID=db1
> }
>
> * CGIs do not have this command environment information, though I guess they could if you remove the relevant ifndefs

That won't be necessary. Without them, they can't reveal any possibly
sensitive data one may want to hide in them. Besides, they'd only be
visible from the "view config" page anyway.

> * Invalid macros in the env variable is treated differently from the command line. For instance, a host check with:
>
> command_line check_tcp $SERVICEDESC$
>
> will cause Nagios to run:
>
> check_tcp $SERVICEDESC$
>
> Which will probably get to the plugin as:
>
> check_tcp $
>
> But the old envvars would set NAGIOS_SERVICEDESC to an empty string. This patch will set to an empty string too. This is controlled by a new process macro option: SET_EMPTY_IF_INVALID.
>

That's fine.

> Also wanted to say that the nagios library has made making functions available much easier and that the kvv stuff is very cool (though a pig to setup).
>

So it begins. Today one happy developer. Tomorrow; The World!
Mwahahahahahahahahaa!

--
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