Unable to use $HOSTNAME$ in Command

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
connected

Unable to use $HOSTNAME$ in Command

Post 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?
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Unable to use $HOSTNAME$ in Command

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
connected

Re: Unable to use $HOSTNAME$ in Command

Post by connected »

The quotes are not working. The output is now "$HOSTNAME$"
I'll send a PM and hope you can help :)
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Unable to use $HOSTNAME$ in Command

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
connected

Re: Unable to use $HOSTNAME$ in Command

Post 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.
You do not have the required permissions to view the files attached to this post.
connected

Re: Unable to use $HOSTNAME$ in Command

Post 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.
You do not have the required permissions to view the files attached to this post.
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Unable to use $HOSTNAME$ in Command

Post 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."
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Locked