[Nagios-devel] Fwd: [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

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

Post by Guest »


--Apple-Mail-76--255155198
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii

Apologies if you receive this twice - resending this as it appears that =
mail from ton.voon@opsview.com appears to be blocked to this mailing =
list.

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
>>=20
>=20
> I was thinking more along the lines of
>=20
> define command {
> env ORACLE_HOME=3D/foo/bar/lala
> env HOST_NAME=3D$HOSTNAME$
> command_name check_something
> command_line /path/to/some-check
> }
>=20
> 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".


>=20
>> I'm happy to do some of this work, but will require agreement on the
>> design and some technical assistance.
>>=20
>=20
> If you get the macros to the workers as kvvec key/value pairs like =
this:
>=20
> k=3Denv
> v=3DNAGIOS_(MACRO_NAME)=3Dmacro value
>=20
> 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?

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

Ton


--Apple-Mail-76--255155198
Content-Disposition: attachment; filename=nagios_worker_macros_research.patch
Content-Type: application/octet-stream;
name="nagios_worker_macros_research.patch"
Content-Transfer-Encoding: 7bit

diff -ur nagios-4.0.20130107/base/checks.c nagios-4.0.20130107.withmacros//base/checks.c
--- nagios-4.0.20130107/base/checks.c 2013-01-11 01:23:09.000000000 +0000
+++ nagios-4.0.20130107.withmacros//base/checks.c 2013-01-14 08:52:03.000000000 +0000
@@ -311,6 +311,13 @@
/* update check statistics */
update_check_stats((scheduled_check == TRUE) ? ACTIVE_SCHEDULED_SERVICE_CHECK_STATS : ACTIVE_ONDEMAND_SERVICE_CHECK_STATS, start_time.tv_sec);

+ /* TODO: Grab only the macros defined in the command definition - this currently forces the first 3 to prove it works*/
+ int free_macro = FALSE;
+ grab_macrox_value_r(&mac, 0, NULL, NULL, &mac.x[0], &free_macro);
+ grab_macrox_value_r(&mac, 1, NULL, NULL, &mac.x[1], &free_macro);
+ grab_macrox_value_r(&mac, 2, NULL, NULL, &mac.x[2], &free_macro);
+ //printf("Setting cmd=%s, %s, %s, %s\n", processed_command, mac.x[0], mac.x[1], mac.x[2]);
+
/* paw off the check to a worker to run */
runchk_result = wproc_run_check(cr, processed_command, &mac);
if (runchk_result == ERROR) {
@@ -2466,6 +2473,13 @@
update_check_stats((scheduled_check == TRUE) ? ACTIVE_SCHEDULED_HOST_CHECK_STATS : ACTIVE_ONDEMAND_HOST_CHECK_STATS, start_time.tv_sec);
update_check_stats(PARALLEL_HOST_CHECK_STATS, start_time.tv_sec);

+ /* TODO: Grab only the macros defined in the command definition - this currently forces the first 3 to prove it works*/
+ int free_macro = FALSE;
+ grab_macrox_value_r(&mac, 0, NULL, NULL, &mac.x[0], &free_macro);
+ grab_macrox_value_r(&mac, 1, NULL, NULL, &mac.x[1], &free_macro);
+ grab_macrox_value_r(&mac, 2, NULL, NULL, &mac.x[2], &free_macro);
+ //printf("Setting cmd=%s, %s, %s, %s\n", processed_command, mac.x[0], mac.x[1], mac.x[2]);
+
runchk_result = wproc_run_check(cr, processed_command, &mac);
if (runchk_result == ERROR) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Unable to run check for ho

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: tonvoon@gmail.com
Locked