Page 1 of 1

Attempting to Use Multiple Variables in Service Template

Posted: Thu May 31, 2018 1:47 pm
by mrochelle
Hello, I've in the process of attempting to use either a host variable or free variable in a service check for monitoring Microsoft queues using a service template but am having a problem with the resolution of either variable type used. Following is the actual service check using the Host free variable:
check_msmqv6_SITE!"MessageCount $HOSTALIAS$\\private$\\commandpayloadprocessorhost_$_HOSTSITE$/commandpayloadprocessorservice.svc 250 500"!!!!!!!

When this command is processed in the nagios xi gui, following is how it is resolved:
Server_FQDN\private$\commandpayloadprocessorhost_$/commandpayloadprocessorservice.svc

As you can see, the free variable $_HOSTSITE$ fails to resolve. I know it's possible that it may be some type of syntax problem with this specific command but I have used the free variable in a number of other service templates without a problem. It appears to be related to the position of the varible in the command. As a test, if I reverse the position of the host free variable with the host variable ($HOSTALIAS$) then the host variable fails to resolve. Reference below:

Host_free_variable\private$\commandpayloadprocessorhost_$/commandpayloadprocessorservice.svc

There appears to be some issue with resolution of the variables toward the middle of the command. I may be trying to perform something that is not allowed. Is it possible to use multiple variables in a single command?
Comments, thoughts are appreciated.
regards, Marcus :geek:

System:
Nagios XI Version : 5.4.13
usiadvs5731.am.bm.net 2.6.32-696.el6.x86_64 x86_64
CentOS release 6.9 (Final)
Gnome is not installed
Apache Information
PHP Version: 5.3.3
Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Server Name: x.x.x.31
Server Address: x.x.x.31
Server Port: 443
Date/Time
PHP Timezone: America/Chicago
PHP Time: Thu, 31 May 2018 13:43:10 -0500
System Time: Thu, 31 May 2018 13:43:10 -0500
Nagios XI Data
License ends in: [Redacted]

nagios (pid 109274) is running...
NPCD running (pid 2612).
ndo2db (pid 2649) is running...
CPU Load 15: 0.46
Total Hosts: 43
Total Services: 1686
Function 'get_base_uri' returns: https://IP/nagiosxi/
Function 'get_base_url' returns: https://IP/nagiosxi/
Function 'get_backend_url(internal_call=false)' returns: https://IP/nagiosxi/includes/components ... rofile.php
Function 'get_backend_url(internal_call=true)' returns: https://localhost/nagiosxi/backend/

Re: Attempting to Use Multiple Variables in Service Template

Posted: Fri Jun 01, 2018 7:10 am
by scottwilkerson
This $ isn't escaped

Code: Select all

private$
and likely throws everything after it off
https://support.nagios.com/kb/article.php?id=580

Re: Attempting to Use Multiple Variables in Service Template

Posted: Fri Jun 01, 2018 7:45 am
by mrochelle
I'll buy next time we meet! Lock it up. That took care of it. :D

Re: Attempting to Use Multiple Variables in Service Template

Posted: Fri Jun 01, 2018 8:03 am
by scottwilkerson
mrochelle wrote:I'll buy next time we meet! Lock it up. That took care of it. :D
I'm gonna hold you to that :lol:

Glad it is resolved.

Locking