ARG value with white space

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
bdoyd1e990
Posts: 12
Joined: Wed Oct 11, 2017 2:57 am

ARG value with white space

Post 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   Send_BMC_service_P2_test!email@test.com!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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: ARG value with white space

Post by npolovenko »

Hello, @ bdoyd1e990.
Try actually putting blank spaces in quotes:

Code: Select all

service_notification_commands   Send_BMC_service_P2_test!email@test.com!2!TEST" "TEAM" "NAME
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
bdoyd1e990
Posts: 12
Joined: Wed Oct 11, 2017 2:57 am

Re: ARG value with white space

Post by bdoyd1e990 »

Just tried that and quoting the white space doesn't work either
getting the same issue
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: ARG value with white space

Post by npolovenko »

@bdoyd1e990, I would like to see how your plugin processes these arguments. Can you upload the P3_send_to_bmc.pl here?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: ARG value with white space

Post 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   Send_BMC_service_P2_test!email@test.com!2!"$USER10$"
Let us know if this helped. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!
bdoyd1e990
Posts: 12
Joined: Wed Oct 11, 2017 2:57 am

Re: ARG value with white space

Post 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   Send_BMC_service_P2_test!email@test.com!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"

Send_BMC_service_P2_test!email@test.com!2!"$USER10$"

--support_group "$ARG3$"
Just in case anyone else needs to use this
This can be closed off now as well
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: ARG value with white space

Post 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!
Former Nagios employee
Locked