Page 1 of 1
Unable to use $HOSTNAME$ in Command
Posted: Thu Jan 21, 2021 10:50 am
by connected
I am trying to create a Command in Nagios XI.
The Command Line is as follows:
$USER1$/check_multi -f /usr/local/nagios/etc/check_multi_cfg/template_multi_Cisco.cmd -s HOSTNAME=$HOSTNAME$ -s HOST=$HOSTADDRESS$ -s STATUSPATH=$ARG1$ -s USERPWD=$ARG2$ -s LOOKFOR=$ARG3$
But when I execute the command the variable $HOSTNAME$ does not seems to be used, it's justed output as text.
/usr/local/nagios/libexec/check_multi -f /usr/local/nagios/etc/check_multi_cfg/template_multi_Cisco.cmd -s HOSTNAME=$HOSTNAME$ -s HOST=192.168.1.10 -s STATUSPATH=/Status/SIP/Profile/Registration/Status -s USERPWD=admin:password -s LOOKFOR=Registered
The other variables work fine. Any clue why this might be?
Re: Unable to use $HOSTNAME$ in Command
Posted: Thu Jan 21, 2021 6:32 pm
by dchurch
Try putting double-quotes around the variable. E.g.
"$HOSTNAME$"
If that doesn't work, can you PM me a system profile so I can diagnose further. Get one by going to Admin (top menu) => System Profile (in the left menu), then clicking the blue button.
If you're unable to generate the the profile through the web interface, please try generating it from the command line by running these commands as root:
Code: Select all
rm -rf /usr/local/nagiosxi/var/components/profile*
/usr/local/nagiosxi/scripts/components/getprofile.sh SUPPORT
Then send me the resulting
/usr/local/nagiosxi/var/components/profile.zip file.
If the profile script fails, please include the ENTIRE output.
Re: Unable to use $HOSTNAME$ in Command
Posted: Fri Jan 22, 2021 11:59 am
by connected
The quotes are not working. The output is now "$HOSTNAME$"
I'll send a PM and hope you can help

Re: Unable to use $HOSTNAME$ in Command
Posted: Fri Jan 22, 2021 5:46 pm
by dchurch
Try replacing "$HOSTNAME$" with $HOSTADDRESS$
The reason I think that variable is used is because $HOSTNAME is exported to the terminal environment when you log into Linux by default. It means something different.
Re: Unable to use $HOSTNAME$ in Command
Posted: Sat Jan 23, 2021 1:55 pm
by connected
$HOSTADDRESS$ returns the IP address and not the hostname.
I've looked at existing check commands and they also don't work.
Quite strange, I assume these are not all programmed incorrectly? See screenshot.
Re: Unable to use $HOSTNAME$ in Command
Posted: Sat Jan 23, 2021 2:26 pm
by connected
Ah, it seems like I'm hitting this issue:
https://support.nagios.com/forum/viewto ... 16&t=50812
So it does work, but not when you test it on the command line or via the GUI.
Issue present in 2018, and still in 2021...
I tested with the
check_dns and it seems to work.
Re: Unable to use $HOSTNAME$ in Command
Posted: Mon Jan 25, 2021 1:51 pm
by dchurch
I noticed that some of your commands are categorized as "misc commands" where they should be "check commands."
If you go into the CCM -> commands list, and open up the command, you should be able to change it to a "check command"
Check commands are used to execute a service or host check. Notably, the macro rules apply differently to check commands, giving available macros such has $HOSTADDRESS$.
"Misc" commands are more generalized commands such as sending an email, running incremental backups, etc.
It's a known issue that certain API actions will reset a command to be "misc."