<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>
<DIV><FONT face=Arial size=2>Matt,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I read the documentation a few times and got the 
impression that macros were not intended to be used in service definitions. The 
following is from the docs:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>Command definitions can contain macros, but you must make sure that you 
include only those macros that are "valid" for the circumstances when the 
command will be used. ... One of the features available in Nagios is the ability 
to use macros in command defintions.</DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>So I do not think you found a bug. Rather I think 
that is how it was intended to work.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- g2</FONT></DIV></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>> Message: 1<BR>> Date: Mon, 9 Feb 2004 15:00:20 -0500 (EST)<BR>> 
From: Matt Pounsett <<A 
href="mailto:matt.pounsett@cira.ca">matt.pounsett@cira.ca</A>><BR>> To: <A 
href="mailto:nagios-users@lists.sourceforge.net">nagios-users@lists.sourceforge.net</A><BR>> 
Subject: [Nagios-users] Bug: resources in service definitions<BR>> <BR>> 
<BR>> I've posted about this before, looking for confirmation from 
others.  I<BR>> haven't received any replies yet.. but I've done some 
more research and I'm<BR>> now convinced this is a bug.  Could I get 
someone to try to duplicate this,<BR>> and let me know if they're 
successful?  This all pertains to Nagios 1.1,<BR>> compiled from source, 
running on RedHat 7.3 and RedHat Edge Server 3.0.<BR>> <BR>> It would 
appear that variables defined in resources.cfg cannot be used inside<BR>> 
service object definitions.. only in command definitions.  When used 
inside<BR>> service definitions, the value that gets passed is always "$", 
rather than the<BR>> value assigned to the variable.<BR>> <BR>> I first 
noticed this when I tried to set up a general mySQL check command.  
I<BR>> have several different mySQL servers to check, some with different 
admin<BR>> passwords, which means that it's easiest for me to define one 
check command,<BR>> and put the user/pass in several sets of resources, 
specified within the<BR>> service definition, like so:<BR>> <BR>> 
resources.cfg:<BR>> --------------<BR>> $USER3$=mysqlroot<BR>> 
$USER4$=mysqlpass<BR>> <BR>> services.cfg:<BR>> --------------<BR>> 
define service {<BR>>     
use                 
templateServiceGeneric<BR>>     
host_name           
sqlserver.domain.com<BR>>     service_description 
MySQL<BR>>     
check_command       
check_mysql!$USER3$!$USER4$<BR>>     
contact_groups      sysadmins<BR>> }<BR>> 
<BR>> commands.cfg:<BR>> ---------------<BR>> define command {<BR>> 
    command_name    check_mysql<BR>> 
    command_line    $USER1$/check_mysql -H 
$HOSTADDRESS$ -u $ARG1$ -p $ARG2$<BR>> }<BR>> <BR>> However... when I 
do it this way, the command that is eventually run is:<BR>> <BR>> 
/usr/local/nagios/libexec/check_mysql -H xx.xx.xx.xx -u $ -p $<BR>> <BR>> 
If I replace $USER3$ for $ARG1$ and $USER4$ for $ARG2$ in the check 
command,<BR>> I get this (as expected):<BR>> <BR>> 
/usr/local/nagios/libexec/check_mysql -H xx.xx.xx.xx -u mysqlroot -p 
mysqlpass<BR>> <BR>> So, in order to get this to work, without exposing 
passwords via the CGI<BR>> interfaces, I've had to create several check 
commands for mySQL -- one for<BR>> each server.  <BR>> <BR>> Could 
someone from the development team confirm whether this is a bug, a<BR>> 
misinterpretation on my part of the documentation (which seems to suggest 
I<BR>> should be able to use resources in service definitions), or some 
other<BR>> intentional limitation in the use of resources?<BR>> <BR>> 
Thanks,<BR>>   Matt Pounsett<BR>> <BR>> -- <BR>> Matt 
Pounsett                 
CIRA - Canadian Internet Registration Authority<BR>> Technical Support 
Programmer                    
350 Sparks Street, Suite 1110<BR>> <A 
href="mailto:matt.pounsett@cira.ca">matt.pounsett@cira.ca</A>                                 
Ottawa, Ontario, Canada<BR>> 613.237.5335 ext. 
231                                      
<A href="http://www.cira.ca">http://www.cira.ca</A></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>