Argument handling

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
Tractor boy
Posts: 5
Joined: Thu Dec 08, 2016 7:16 am

Argument handling

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Argument handling

Post 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.
Former Nagios employee
Tractor boy
Posts: 5
Joined: Thu Dec 08, 2016 7:16 am

Re: Argument handling

Post 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.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Argument handling

Post 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
Tractor boy
Posts: 5
Joined: Thu Dec 08, 2016 7:16 am

Re: Argument handling

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Argument handling

Post 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.
Former Nagios Employee
Locked