Page 1 of 1

Passing parameters to NCPA plugin in 2.1.6

Posted: Mon Mar 18, 2019 12:24 pm
by corkyman
I used to have this format for passing parameters to my NCPA plugins that worked fine: -a '<arg1> <arg2>'. This worked fine in 1.8.1.
With ncpa 2.1.6 it does not work.

-bash-4.1$ /usr/local/nagios/libexec/check_ncpa.py -H shlgnwsad011.tvlport.net -t wspwebfarm -M api/plugins/check_File_Recent.sh -a'/tmp/test 5'
find: missing argument to `-mmin'
Ok. File was not recently created

If I rework the way i pass the arguments then it works fine.

-bash-4.1$ /usr/local/nagios/libexec/check_ncpa.py -H shlgnwsad011.tvlport.net -t wspwebfarm -M api/plugins/check_File_Recent.sh -q 'args="/tmp/test",args=5'
Ok. File was not recently created
-bash-4.1$

I don't think this was documented.

Re: Passing parameters to NCPA plugin in 2.1.6

Posted: Mon Mar 18, 2019 1:01 pm
by corkyman
I can circumvent the problem by adding double quotes around the argument that specifies the path. Looks like treatment of the forward slashes changed in 2.1.6

Re: Passing parameters to NCPA plugin in 2.1.6

Posted: Mon Mar 18, 2019 1:02 pm
by npolovenko
Hello, @corkyman. Both options seem to be working for me. Can you upload your plugin so I can test it out in the lab?

Re: Passing parameters to NCPA plugin in 2.1.6

Posted: Mon Mar 18, 2019 1:04 pm
by corkyman
It seems that the problem occurs for arguments containing file paths. Have you tried that? I'll upload the plugin.

Re: Passing parameters to NCPA plugin in 2.1.6

Posted: Mon Mar 18, 2019 1:06 pm
by corkyman
check_File_Recent.sh
---------------------------------
#!/bin/bash

# Tests file age to check if it was recently updated
# Input args:
# file_path - file name including the path
# age - file age in minutes to check against
# Output:
# Ctritical alert if file is younger than <age> minutes

file_path=$1
age=$2

if test `find "$1" -mmin -$2`
then
retCode=1
echo "Warning. File was recently created"
else
retCode=0
echo "Ok. File was not recently created"
fi

exit $retCode

Re: Passing parameters to NCPA plugin in 2.1.6

Posted: Mon Mar 18, 2019 1:07 pm
by corkyman
plugin is uploaded as an attachment

Re: Passing parameters to NCPA plugin in 2.1.6

Posted: Mon Mar 18, 2019 2:18 pm
by npolovenko
@corkyman, I see. Seems like the NCPA does expect arguments in a format you specified.
Untitled.png
I will submit an internal request to update syntax in our documentation.