checkfiles custom variables not being called?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
j4rt
Posts: 3
Joined: Thu Aug 29, 2013 5:21 pm

checkfiles custom variables not being called?

Post 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?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: checkfiles custom variables not being called?

Post 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?
j4rt
Posts: 3
Joined: Thu Aug 29, 2013 5:21 pm

Re: checkfiles custom variables not being called?

Post by j4rt »

In the host definition I have the variable defined as:

_dir1 C:\temp
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: checkfiles custom variables not being called?

Post 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!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
j4rt
Posts: 3
Joined: Thu Aug 29, 2013 5:21 pm

Re: checkfiles custom variables not being called?

Post 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.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: checkfiles custom variables not being called?

Post 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
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked