Page 1 of 1

checkfiles custom variables not being called?

Posted: Thu Aug 29, 2013 5:26 pm
by j4rt
I have this command:
$USER1$/check_nrpe debug=1 -H $HOSTADDRESS$ -c CheckFiles -a "path=$_HOSTDIR1$" "pattern=$ARG1$" "filter=written > -$ARG2$" truncate=4096 "syntax=%filename%: %write%" MaxWarn=1
In the host definition I have custom variable "_HOSTDIR1" defined with "C:\temp"

However, unlike this command (with custom variable):
$USER1$/check_ping -H $_HOSTISP1$ -w $ARG1$ -c $ARG2$ -p 5
The command returns:

"Missing path argument"

Also, if I put the path directly in the service definition, everything works great:
$USER1$/check_nrpe debug=1 -H $HOSTADDRESS$ -c CheckFiles -a "path=C:\temp" "pattern=$ARG1$" "filter=written > -$ARG2$" truncate=4096 "syntax=%filename%: %write%" MaxWarn=1
Why won't my custom variable pass through to the service?

Re: checkfiles custom variables not being called?

Posted: Fri Aug 30, 2013 9:29 am
by slansing
Also, if I put the path directly in the service definition, everything works great:
$USER1$/check_nrpe debug=1 -H $HOSTADDRESS$ -c CheckFiles -a "path=C:\temp" "pattern=$ARG1$" "filter=written > -$ARG2$" truncate=4096 "syntax=%filename%: %write%" MaxWarn=1
Why won't my custom variable pass through to the service?
Where do you have $_HOSTDIR1$ defined?

Re: checkfiles custom variables not being called?

Posted: Fri Aug 30, 2013 10:58 am
by j4rt
In the host definition I have the variable defined as:

_dir1 C:\temp

Re: checkfiles custom variables not being called?

Posted: Fri Aug 30, 2013 1:17 pm
by sreinhardt
The _HOSTDIR value needs to be in the service config. Having it in the host config will not pass through to the service. Define it exactly as you do for the host, but in the service, not as the _dir value and this should work fine. Report back to let us know please!

Re: checkfiles custom variables not being called?

Posted: Fri Aug 30, 2013 1:27 pm
by j4rt
Thank you for the replies.

In the service definition I have:

_dir1 C:\temp

But it returns the same.

Maybe there is a different way to do this? What I need to do is have the service automatically created when I create a host with custom variables. I go this working with:
$USER1$/check_ping -H $_HOSTISP1$ -w $ARG1$ -c $ARG2$ -p 5
and have "_isp1 192.168.0.1" in the host definition and those services are automatically created - so all I have to do is create the host.

Re: checkfiles custom variables not being called?

Posted: Fri Aug 30, 2013 1:34 pm
by sreinhardt
You need to use _SERVICEDIR in the command definition not _hostdir. As stated it doesn't pull from the host object, but the service prefix will tell it to use the value stored in the service object. (admittedly I had to be corrected by a coworker on _host\_service usage). Take a look at the link below and specifically at the table towards the bottom on usage.

http://nagios.sourceforge.net/docs/3_0/ ... tvars.html