Passing parameter containing / to NCPA plugin

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

Passing parameter containing / to NCPA plugin

Post by corkyman »

I have upgraded some of my NCPA agents to 2.1.6 from 1.8.1 and there is a difference in how parameters are passed to plugins when parameters contain '/.'. Please see below:
1.8.1:
[c601018@vhlgnngxi001 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H sclpnekbb001.tvlport.net -t wspwebfarm -M agent/plugin/check_status_cassandra.sh -a "/apps02/tpworkdir/status.log Cassandra_Cluster_Status"
OK: RTDP Cassandra_Cluster_Status is Up

2.1.6:
[c601018@vhlgnngxi001 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H sclppekbb003.tvlport.net -t wspwebfarm -M api/plugins/check_status_cassandra.sh -a "/apps02/tpworkdir/status.log Cassandra_Cluster_Status" WARNING: RTDP apps02 not found

To fix it I had to put the argument containing / in single quotes:
[c601018@vhlgnngxi001 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H sclppekbb003.tvlport.net -t wspwebfarm -M api/plugins/check_status_cassandra.sh -a "'/apps02/tpworkdir/status.log' Cassandra_Cluster_Status"
OK: RTDP Cassandra_Cluster_Status is Up

Unfortunately, I cannot make this change beforehand to my service checks because after putting single quotes around arguments in 1.8.1 does not work:
[c601018@vhlgnngxi001 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H sclpnekbb001.tvlport.net -t wspwebfarm -M agent/plugin/check_status_cassandra.sh -a "'/apps02/tpworkdir/status.log' Cassandra_Cluster_Status"
WARNING: RTDP '/apps02/tpworkdir/status.log' not found

So I have to make the change right after I upgrade the agent. Given the number of agents that are being upgraded at the same time (hundreds) it is a very time consuming task to update service checks as well at the time the change is scheduled.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Passing parameter containing / to NCPA plugin

Post by npolovenko »

Hello, @corkyman. We have both versions of NCPA in the lab and we ran our checks successfully with / arguments. We wrapped the whole arguments section in double quotes(like you have in the 1.8.1 example, but also in single quotes and didn't encounter problems either way. I wonder if this is somehow related to the plugin. Can you share the check_status_cassandra.sh with us in the thread?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

Re: Passing parameter containing / to NCPA plugin

Post by corkyman »

Attached
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Passing parameter containing / to NCPA plugin

Post by lmiltchev »

Can you also give us an example of the format of the '/apps02/tpworkdir/status.log'?
Be sure to check out our Knowledgebase for helpful articles and solutions!
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

Re: Passing parameter containing / to NCPA plugin

Post by corkyman »

Attached
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Passing parameter containing / to NCPA plugin

Post by lmiltchev »

I tested various combinations, but unfortunately it is not possible to use the same command for both, the old, and the new agent. :(

These are two major versions of NCPA, where lots of changes took place. Even if wrapping the arguments in single or double quotes worked the same, the part after the "-M" flag wouldn't work the same...

Since you will be eventually upgrading your NCPA agents to the latest anyway, I would recommend that you set up your commands either as this one:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H sclppekbb003.tvlport.net -t wspwebfarm -M api/plugins/check_status_cassandra.sh -a "'/apps02/tpworkdir/status.log' Cassandra_Cluster_Status" 
or this one:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H sclppekbb003.tvlport.net -t wspwebfarm -M api/plugins/check_status_cassandra.sh -q 'args=/apps02/tpworkdir/status.log,args=Cassandra_Cluster_Status'
or:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H sclppekbb003.tvlport.net -t wspwebfarm -M api/plugins/check_status_cassandra.sh -q 'args=/apps02/tpworkdir/status.log Cassandra_Cluster_Status'
or

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H sclppekbb003.tvlport.net -t wspwebfarm -M api/plugins/check_status_cassandra.sh -q "args=/apps02/tpworkdir/status.log Cassandra_Cluster_Status"
To avoid doing everything manually, you could use a sed command (find/replace), and modify bunch of configs in bulk. You can then drop them in the /usr/local/nagios/etc/import directory, and run the /usr/local/nagiosxi/scripts/reconfigure_nagios.sh script.

Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

Re: Passing parameter containing / to NCPA plugin

Post by corkyman »

Thank you for confirming my findings and a recommendation. I will use a different approach that we've used to modify the -M param--using Nagios API to modify the service checks.
Thanks for your help, you may close this case.
Locked