User defined macros/variables


#1

Hello,
Firstly may I say that that I am a bit of a nagios noob although am already hooked! My problem is as follows:
Nagios version: 2.5
I have set up a http check command to monitor the status of mysql like so:

define command{
command_name check_mysql
command_line $USER1$/check_http -H $HOSTADDRESS$ -s “The database is working” -u $ARG1$
}

I have also set up a service to call this but my problem is that the URL that I’m passing to the command is specific to the host and so I really need to define the url in the host definition as a user defined variable.
if I try and add a line like:
_url "http://host1.servers.com/check_mysql.php"
I get an error like this:
Error: Invalid host object directive ‘_url’.
Error: Could not add object property in file ‘/etc/nagios/hosts.cfg’ on line 121.
Is this kind of thing only available in version 3? And if so how can I do this without creating a service for each host?
Thanks in advance…


#2

I believe you have to define your custom macros in all caps. So it would be:

_URL “http://…”

Give it a try.