NCPA Powershell Plugin trouble passing arguments

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
cordeliaf40
Posts: 1
Joined: Mon May 27, 2024 7:08 am

NCPA Powershell Plugin trouble passing arguments

Post by cordeliaf40 »

Hello guys,

Yesterday, I am having trouble passing parameters using a custom powershell plugin from a Windows machine running the NCPA 3.0.0.client.

To help with testing, I wrote the following PS script:

Code: Select all

param (
[string]$F='John',
[string]$L='Doe',
[string]$M='E'
)

write-host "Success! $($F) $($M) modified $($L)."
Exit 0
Then, I try passing parameters, initially with Powershell named parameters like -F Joe -L Donuts, but that didn't work at all. Eventually I settled on using positional parameters, but have had issues getting that to work as well.

To test, I am modifying the nrdp.cfg on the Windows machine, restarting the service and then going to http://localhost:5693/gui/checks.download lagu

I have tried lots of combinations with varying results. For example:

Code: Select all

%HOSTNAME%|TestArgs = plugins/testargs.ps1 --args Joe Donuts S"
returns Joe E Doe

Here are some of my notes, sorry they are a little disorganized. Keep in mind F used to be First, M - Middle, L - Last
-a did not work
--args 'G K B' not working at all
--args 'G,K,B' treats as first argument only
--args '-First G' not working
--args '--First G' not working
--args "-First G" not working
--args "-First 'G'"
--args -First G - specify a system string
--args -First "G" - Same
--args -First 'G' - Same
--args 'G','k' recognized first two params, but included quotes
--args Gar,k combined into 1 parameter.
--args "Gar ak","k" not working at all - Same with single quotes - doesn't seem to like spaces.
Gar,F,Eild - combined
"Gar","F","Eild" - correclty set first to "Gar" but combimed "F","Eild" together for last
"Gar,F,Eild" - combined into first
bbahn
Posts: 385
Joined: Thu Jan 12, 2023 5:42 pm

Re: NCPA Powershell Plugin trouble passing arguments

Post by bbahn »

Hello @cordeliaf40,

This topic has already been answered here: viewtopic.php?p=356824&hilit=ncpa+powershell#p356824
For your PowerShell script to process the arguments correctly, you want the CLI input to be
plugins/plugin.ps1 "arg1" "arg2" "arg3"
To get this behavior as a passive check, you can use
%HOSTNAME%|TEST = plugins/test.ps1 --args "arg1" --args "arg2" --args "arg3"
You can more intuitively figure out how to properly configure your plugin inputs by first going through the NCPA UI at https://your_NCPA_ip_address:5693/gui/api/ and selecting plugins and pluginname.ps1 and then entering your arguments into the argument box and adding arguments as necessary until you get your desired result.
Actively advancing awesome answers with ardent alliteration, aptly addressing all ambiguities. Amplify your acumen and avail our amicable assistance. Eagerly awaiting your astute assessments of our advice.
Post Reply