patch for preprocessing macros
Ethan Galstad
nagios at nagios.org
Thu Aug 16 15:51:48 CEST 2007
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: nagios at nagios.org
Website: http://www.nagios.org
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
More information about the Developers
mailing list