Page 1 of 1

Argument handling

Posted: Thu Dec 08, 2016 7:47 am
by Tractor boy
Hi, I am new to good and am struggling with the basics .

I have updated a script to have a new parameter and have found d all the files that need updating to join everything together, so first challenge complete. Trouble now is that my parameter is complicated and includes various characters including spaces.

I am really struggling to understand where the issues lies or how to investigate.

Just out of interest the parameter is file_name floor 'text.*text'

Have found a command expansion page and that seems to show that the parameter is being treated as multiple parameters

I am on Linux if that makes any difference.

Thanks for reading and any suggestions.

If like to understand how to debug the layers to see where things are going wrong as well as ideas on how to resolve

Thanks

Re: Argument handling

Posted: Thu Dec 08, 2016 10:05 am
by tmcdonald
Can you post the source code here? If this is just a general programming question it should be asked in a forum focused on programming.

Re: Argument handling

Posted: Thu Dec 08, 2016 10:36 am
by Tractor boy
Sorry haven't got access to nagios source. The issue is that I need to pass the argument but nagios isn't able to accept the required characters. My shells script is fine, and will work once I can get nagios to accept and pass the parameter as required.

in this case its the 4th parameter. So the command is configured to accept 4 parameters as "$ARG1$" "$ARG$2" etc. if I pass basic characters ie 0 or abcd or whatever then everything is fine and the parameter is read by the shells script, but send a ' and I start getting errors.

Re: Argument handling

Posted: Thu Dec 08, 2016 5:15 pm
by ssax
If you are passing a ', try passing it with it escaped: \'

If that still doesn't work, please post your command definition (/usr/local/nagios/etc/commands.cfg) and your service definition (/usr/local/nagios/etc/services/CONFIGNAME.cfg) so that we can debug more.

Thank you

Re: Argument handling

Posted: Mon Dec 12, 2016 7:59 am
by Tractor boy
Hi

Hope this helps

check_command COMMANDNAME!ARGUMENT1!10!MINUTE!"file_name rlike 'DR[0-9]*.DAT.gz'"


command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c COMMANDNAME -a $ARG1$ $ARG2$ $ARG3$ $ARG4$

I have had to remove pertinent information, but everything works, including the 4th parameter until ' added. I have tried to escape them, and also included and excluded the double quotes.

Re: Argument handling

Posted: Mon Dec 12, 2016 11:09 am
by rkennedy
Can you post the plugin you're attempting to use as well? If the escaping doesn't work, and your encapsulating properly, I would think that the plugin may not be accepting it properly.