$HOSTNAME$ in commands? (Was: Re: Monitoring a matrix of load-balanced VirtualHosts?)

Chris Wilson chris at aidworld.org
Wed Aug 31 11:44:16 CEST 2005


Hi JB,

> I've been told to check '{machinename}.foo.com', but - according to
> docs/macros.html - I can't use $HOSTNAME$ or $HOSTALIAS$ in either
> host or service checks.
> 
> My 1st instinct is to do just that - something like
>         check_command           check_lb_vhost!$HOSTNAME$.foo.com
> 
> but it seems I can't. This is more than a bit annoying, and seems a
> very odd design decision. I can't be the only one who wants this
> functionality.

I agree that that is very odd. The information must be available, and
you could probably patch Nagios to make those macros work.

Looking at the source code, it should work now. base/checks.c grabs all
macros for hosts and services before running the check. The only problem
might be the nesting of macros, which I haven't tried and don't know if
it works. You could try this:

	define service {
                use                     vhost-service
                service_description     $HOSTNAME$.bar.com
                check_command           my_check_http_on_host!bar.com
                hostgroup_name          bar_com_servers
        }
        
        define command {
                command_name    my_check_http_on_host
                command_line    $USER1$/check_http -I $HOSTADDRESS$ -H
        $HOSTNAME$.$ARG1$
        }

If not, let me know (with details about exactly what happens when you
try) and I'll have another look. Or maybe a higher guru will.

Cheers, Chris.
-- 
(aidworld) chris wilson | chief engineer (chris at aidworld.org)



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list