Page 1 of 1

ARG value with white space

Posted: Wed Mar 21, 2018 4:56 am
by bdoyd1e990
Im trying to setup a number of contacts that will all call the same script but pass a variable for there team name using ARG macros,
The problem is that most if not all these team names have spaces which is stopping my config from reloading.

My command is (i've removed all the other options for send_to_bmc.pl just to make this easier to read) :

Code: Select all

define command{
        command_name    Send_BMC_service_P2_test
        command_line    $USER1$/P3_send_to_bmc.pl --email "$ARG1$" --nag_priority "$ARG2$" --support_group "$ARG3$"
}
Example contact :

Code: Select all

define contact{
        contact_name                    LINUX_BMC_P2_CRITICAL_TEST
        alias                           LINUX_BMC_P2_CRITICAL_TEST
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    c,u,r
        host_notification_options       d,u,r,f,s
        service_notification_commands   [email protected]!2!"TEST TEAM NAME"
        host_notification_commands       Send_BMC_host_P2_test
        register                        1
        }
Output when i run a check config :

Code: Select all

[root objects]# nagios checkconfig
Running configuration check... CONFIG ERROR!  Check your Nagios configuration.
Error: Service notification command 'NAME"' specified for contact 'LINUX_BMC_P2_CRITICAL_TEST' is not defined anywhere!
Error: Service notification command 'TEAM' specified for contact 'LINUX_BMC_P2_CRITICAL_TEST' is not defined anywhere!
I've tried removing the double quotes around the $ARG#$'s in the command definition, and i've tried using single quotes in the contact definition but neither has worked.

Re: ARG value with white space

Posted: Wed Mar 21, 2018 4:57 pm
by npolovenko
Hello, @ bdoyd1e990.
Try actually putting blank spaces in quotes:

Code: Select all

service_notification_commands   [email protected]!2!TEST" "TEAM" "NAME

Re: ARG value with white space

Posted: Thu Mar 22, 2018 9:49 am
by bdoyd1e990
Just tried that and quoting the white space doesn't work either
getting the same issue

Re: ARG value with white space

Posted: Thu Mar 22, 2018 4:38 pm
by npolovenko
@bdoyd1e990, I would like to see how your plugin processes these arguments. Can you upload the P3_send_to_bmc.pl here?

Re: ARG value with white space

Posted: Thu Mar 22, 2018 4:53 pm
by lmiltchev
@bdoyd1e990, try placing the last argument to a user macro, in the "/usr/local/nagios/etc/resource.cfg" file.

Example:

Code: Select all

$USER10$="TEST TEAM NAME"
Then, you can use the macro as $ARG3$:

Code: Select all

service_notification_commands   [email protected]!2!"$USER10$"
Let us know if this helped. Thanks!

Re: ARG value with white space

Posted: Fri Mar 23, 2018 5:04 am
by bdoyd1e990
lmiltchev wrote:@bdoyd1e990, try placing the last argument to a user macro, in the "/usr/local/nagios/etc/resource.cfg" file.

Example:

Code: Select all

$USER10$="TEST TEAM NAME"
Then, you can use the macro as $ARG3$:

Code: Select all

service_notification_commands   [email protected]!2!"$USER10$"
Let us know if this helped. Thanks!
Yeh this worked perfectly,
Thanks for the help, the only thing to point out is I had to use double quotes everywhere ie
in resource.cfg, contacts definition & the command definition eg :

Code: Select all

$USER10$="TEST TEAM NAME"

[email protected]!2!"$USER10$"

--support_group "$ARG3$"
Just in case anyone else needs to use this
This can be closed off now as well

Re: ARG value with white space

Posted: Fri Mar 23, 2018 9:34 am
by tmcdonald
Glad to hear it! I'll be closing this up now, but feel free to open another thread if you need anything in the future!