Page 1 of 1

Change default to use single quotes

Posted: Thu Sep 13, 2018 3:22 pm
by liebherrjohan
Hello,

I require help with the creation of services for a host.

When using the Network Switch wizard to add a switch to Nagios XI the wizard completes successfully. The wizard creates the following check command for interface status (passphrase has been replaced with ****):

/usr/local/nagios/libexec/check_ifoperstatnag PORTNUMBER -v3 -u USERNAME -A "********" -x AES -X "********" -a SHA -l authPriv IP_OF_SWITCH

The check command does not complete successfully. After some troubleshooting I discovered that it was the double-quotes in the command. When I change the check command to use single quotes, the command executes successfully.

The question is how do I change the default behavior of Nagios to use single quotes when adding a new host with services to the system? I have several hundred ports to add, and do not want to modify each port manually.

Thank you,
Johan

Re: Change default to use single quotes

Posted: Thu Sep 13, 2018 4:07 pm
by npolovenko
Hello, @liebherrjohan. I think the reason why double quotes are failing is likely because you're using some special characters in the password and Nagios is not able to escape them properly.
I suggest creating a custom macro with the password in the resource.cfg file, and in the network switch/router wizard in the password field insert the macro instead of the actual password.
https://assets.nagios.com/downloads/nag ... Macros.pdf
$USER10$=YourPassword

Re: Change default to use single quotes

Posted: Fri Sep 14, 2018 9:03 am
by liebherrjohan
Hi,

I have done the steps to do this:

1: Added $USER9$=PASSPHRASE_HERE to the resource.cfg file
2: Used the $USER9$ in the password field during the network switch/router wizard

The initial scan completes successfully, but the status for each port is still failing with "UNKNOWN - No info is being retrieved."

I checked the command created by the wizard and it is now:

check_xi_service_ifoperstatusnag!8!-v3 -u USERNAME -A "$USER9$" -x AES -X "$USER9$" -a SHA -l authPriv

Please advise,
Johan

Re: Change default to use single quotes

Posted: Fri Sep 14, 2018 10:06 am
by liebherrjohan
npolovenko wrote:Hello, @liebherrjohan. I think the reason why double quotes are failing is likely because you're using some special characters in the password and Nagios is not able to escape them properly.
I suggest creating a custom macro with the password in the resource.cfg file, and in the network switch/router wizard in the password field insert the macro instead of the actual password.
https://assets.nagios.com/downloads/nag ... Macros.pdf
$USER10$=YourPassword
This had the same results with the exception that the command now has the $USER9$ in the command rather than the password.

The initial scan during the wizard runs fine, but the services show "UNKNOWN - No info is being retrieved."

Thank you,
Johan

Re: Change default to use single quotes

Posted: Fri Sep 14, 2018 11:41 am
by npolovenko
@liebherrjohan, This is how it should be. If you save this config and go to the home page Nagios will automatically replace $USER9$ with the macro in the recource.cfg file.
I checked the command created by the wizard and it is now:

check_xi_service_ifoperstatusnag!8!-v3 -u USERNAME -A "$USER9$" -x AES -X "$USER9$" -a SHA -l authPriv
Can you replace double quotes with single quotes around the "$USER9$" and let me know if the check starts working on the Home dashboard?
You can also try wrapping the password in single quotes in the resource.cfg file.

Re: Change default to use single quotes

Posted: Mon Sep 17, 2018 3:13 pm
by liebherrjohan
Good day,

I added the single quotes to the resource.cfg and then edited the command and took out the double quotes. This works.

resource.cfg:
$USER9$='abcdefg'

check command:
check_xi_service_ifoperstatusnag!8!-v3 -u USERNAME -A $USER9$ -x AES -X $USER9$ -a SHA -l authPriv

When I try to add a host using the same macro ($USER9$) the initial scan does not complete. When I remove the single quotes from the resource.cfg the initial scan does complete again.

Re: Change default to use single quotes

Posted: Mon Sep 17, 2018 3:35 pm
by npolovenko
@liebherrjohan, Let's try the following. Leave the config with the original double quotes. In the resource.cfg file, in your password escape all special characters with "\". So before characters like $ or ! put \. For example, \$ .
Let me know if it works for you.

Re: Change default to use single quotes

Posted: Tue Sep 18, 2018 7:57 am
by liebherrjohan
Good morning,

I have tried inserting the \ before the special character. This caused the command to add the \ to the password instead of using it as an escape character.

I also attempted to enter the password in the configuration wizard using the escape character which resulted in the same results as above.

Another test was running through the configuration wizard using the $USER9$ (which I changed to the actual password WITHOUT escape character) and completing the wizard. After the wizard finished successfully, I then changed $USER9$ to INCLUDE the escape character. This worked.

I did notice something; when I tried it the troubleshooting tip shows the command with SINGLE quotes. I am just thinking out loud, but does this mean when the configuration wizard runs, it scans using SINGLE quotes, but when you create the services at the end of the configuration wizard, the wizard configures the services with DOUBLE quotes?

Re: Change default to use single quotes

Posted: Tue Sep 18, 2018 10:54 am
by npolovenko
@liebherrjohan, This is likely considering that the logic to scan ports/do an SNMP walk and actually writing out configs is separated in the wizard. Can you PM me with the name of the special character that you used? I will pass this information to the Dev team for further troubleshooting.