Re: [Nagios-devel] patch for preprocessing macros

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 for preprocessing macros

Post by Guest »

Matthias Eble wrote:
> Hi list,
>
> we moved check_cluster from contrib to the main distribution of the
> nagios plugins a couple of days ago. While writing the test cases, I
> remembered that I had had an issue to flexibly configure service
> clusters months ago, so i wrote a small patch to meet these needs
> (although i developed a workaround at that time).
>
> The problem:
> If there are multiple checks for one server process, eg. apache on port
> 80 and port 443 a corresponding service cluster has to have a command
> line similar to this one:
>
> check_cluster -s \
> -d $SERVICESTATEID:myhost1:Port 443$,$SERVICESTATEID:myhost1:Port 80$
>
> Templates cannot be used since myhost1 cannot be substituted by the
> $HOSTNAME$ macro due to nagios' macro substitution logic resulting in
> one service config for each host.
>
> So i wrote a patch that can handle macros in on demand macros.
>
> I originally thought about syntax like $SERVICESTATEID:$HOSTNAME$:Port$
> but I couldn't imagine a way to distinguish between opening and closing
> $ signs. So my syntax contains braces and looks like this:
>
> $SERVICESTATEID:{$HOSTNAME$}:svc_desc$
>
> The code substitutes macros in curly braces first.
>
> What do you think about it?
>
> Thanks
> Matthias
[snip]

Thanks for the patch Matthias. Its a few months old, but I kept it on
my TODO list. I think I'll reimplement the patch as a recursive
function that allows multiple levels of nesting. Not sure if multiple
levels are absolutely necessary, but the functionality will be there if
someone needs it.


Ethan Galstad,
Nagios Developer
---
Email: [email protected]
Website: http://www.nagios.org





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked