[PATCH] Fix default value for enable_environment_macros

Ton Voon ton.voon at opsview.com
Wed Jan 16 11:24:09 CET 2013


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
  * There's an assumption that putenv() is available
  * I've added an example in sample-config with notes:

# 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
  * 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.

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

Ton
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nagios_command_environment_macros.patch
Type: application/octet-stream
Size: 33598 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20130116/8f2a8653/attachment.obj>
-------------- next part --------------
------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list