Bug: resources in service definitions

gasman2 gasman2 at hotmail.com
Wed Feb 11 17:34:06 CET 2004


Matt,

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:

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.

So I do not think you found a bug. Rather I think that is how it was intended to work.

- g2


> Message: 1
> Date: Mon, 9 Feb 2004 15:00:20 -0500 (EST)
> From: Matt Pounsett <matt.pounsett at cira.ca>
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] Bug: resources in service definitions
> 
> 
> I've posted about this before, looking for confirmation from others.  I
> haven't received any replies yet.. but I've done some more research and I'm
> now convinced this is a bug.  Could I get someone to try to duplicate this,
> and let me know if they're successful?  This all pertains to Nagios 1.1,
> compiled from source, running on RedHat 7.3 and RedHat Edge Server 3.0.
> 
> It would appear that variables defined in resources.cfg cannot be used inside
> service object definitions.. only in command definitions.  When used inside
> service definitions, the value that gets passed is always "$", rather than the
> value assigned to the variable.
> 
> I first noticed this when I tried to set up a general mySQL check command.  I
> have several different mySQL servers to check, some with different admin
> passwords, which means that it's easiest for me to define one check command,
> and put the user/pass in several sets of resources, specified within the
> service definition, like so:
> 
> resources.cfg:
> --------------
> $USER3$=mysqlroot
> $USER4$=mysqlpass
> 
> services.cfg:
> --------------
> define service {
>     use                 templateServiceGeneric
>     host_name           sqlserver.domain.com
>     service_description MySQL
>     check_command       check_mysql!$USER3$!$USER4$
>     contact_groups      sysadmins
> }
> 
> commands.cfg:
> ---------------
> define command {
>     command_name    check_mysql
>     command_line    $USER1$/check_mysql -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$
> }
> 
> However... when I do it this way, the command that is eventually run is:
> 
> /usr/local/nagios/libexec/check_mysql -H xx.xx.xx.xx -u $ -p $
> 
> If I replace $USER3$ for $ARG1$ and $USER4$ for $ARG2$ in the check command,
> I get this (as expected):
> 
> /usr/local/nagios/libexec/check_mysql -H xx.xx.xx.xx -u mysqlroot -p mysqlpass
> 
> So, in order to get this to work, without exposing passwords via the CGI
> interfaces, I've had to create several check commands for mySQL -- one for
> each server.  
> 
> Could someone from the development team confirm whether this is a bug, a
> misinterpretation on my part of the documentation (which seems to suggest I
> should be able to use resources in service definitions), or some other
> intentional limitation in the use of resources?
> 
> Thanks,
>   Matt Pounsett
> 
> -- 
> Matt Pounsett                 CIRA - Canadian Internet Registration Authority
> Technical Support Programmer                    350 Sparks Street, Suite 1110
> matt.pounsett at cira.ca                                 Ottawa, Ontario, Canada
> 613.237.5335 ext. 231                                      http://www.cira.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20040211/7466c804/attachment.html>


More information about the Users mailing list