Problem with plugins and arguments with special characters

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
sgomeztd
Posts: 37
Joined: Tue Apr 30, 2019 11:00 am

Problem with plugins and arguments with special characters

Post by sgomeztd »

I'm trying to make a plugin work that requires very specific argument that I have not being able to make it work due to the format it requires.

This is the plugin I'm using
https://exchange.nagios.org/directory/P ... ck/details

I have tried passing the argument is multiple format but no matter how I try I have only managed to make it work in one specific way an which a single argument.

Here is misunterpreting the : after test because those : shouldn't be there

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 192.168.1.1 -t 'xxxxxxxxxxxxxxxxxx' -P 5693 -M 'plugins/check_ad.vbs' -T 600 -a "'/test:Advertising,DFSREvent,SysVolCheck,KccEvent,MachineAccount'" -vvv
Connecting to: https://192.168.1.1:5693/api/plugins/check_ad.vbs/%27%2Ftest%3AAdvertising%2CDFSREvent%2CSysVolCheck%2CKccEvent%2CMachineAccount%27?token=xxxxxxxxxxxxxxx&check=1
File returned contained:
{"returncode": 2, "stdout": "CRITICAL - :Advertising: CRITICAL. DFSREvent: CRITICAL. SysVolCheck: CRITICAL. KccEvent: CRITICAL. MachineAccount': CRITICAL.", "cmd": "cscript C:\\Program Files\\Nagios\\NCPA\\plugins\\check_ad.vbs '/test:Advertising,DFSREvent,SysVolCheck,KccEvent,MachineAccount' //NoLogo"}
CRITICAL - [b]:[/b]Advertising: CRITICAL. DFSREvent: CRITICAL. SysVolCheck: CRITICAL. KccEvent: CRITICAL. MachineAccount': CRITICAL.
These two no idea what why is not working

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 192.168.1.1 -t 'xxxxxxxxx' -P 5693 -M 'plugins/check_ad.vbs' -T 600 -q 'args=/test:Advertising,DFSREvent,SysVolCheck,KccEvent,MachineAccount' -vvv
An error occurred:
not enough values to unpack (expected 2, got 1)

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 192.168.1.1 -t 'xxxxxxxxx' -P 5693 -M 'plugins/check_ad.vbs' -T 600 -q "args=/test:Advertising,DFSREvent,SysVolCheck,KccEvent,MachineAccount" -vvv
An error occurred:
not enough values to unpack (expected 2, got 1)
Here is removing the / before test

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 192.168.1.1 -t 'xxxxxxxxxxxxxxx' -P 5693 -M 'plugins/check_ad.vbs' -T 600 -a "/test:Advertising" -vvv
Connecting to: https://192.168.1.1:5693/api/plugins/check_ad.vbs/%2Ftest%3AAdvertising?token=xxxxxxxxxxxxxxx&check=1
File returned contained:
{"returncode": 3, "stdout": "UNKNOWN - Invalid arguments :test:Advertising , use /help for list of valid arguments", "cmd": "cscript C:\\Program Files\\Nagios\\NCPA\\plugins\\check_ad.vbs test:Advertising //NoLogo"}
UNKNOWN - Invalid arguments :test:Advertising , use /help for list of valid arguments
Here is removing / as well

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 192.168.1.1 -t 'xxxxxxxxxxxxxxx' -P 5693 -M 'plugins/check_ad.vbs' -T 600 -a '/test:Advertising' -vvv
Connecting to: https://192.168.1.1:5693/api/plugins/check_ad.vbs/%2Ftest%3AAdvertising?token=xxxxxxxxxxxxxxx&check=1
File returned contained:
{"returncode": 3, "stdout": "UNKNOWN - Invalid arguments :test:Advertising , use /help for list of valid arguments", "cmd": "cscript C:\\Program Files\\Nagios\\NCPA\\plugins\\check_ad.vbs test:Advertising //NoLogo"}
UNKNOWN - Invalid arguments :test:Advertising , use /help for list of valid arguments
A single arguments works like this

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 192.168.1.1 -t 'xxxxxxxxxxxxxxx' -P 5693 -M 'plugins/check_ad.vbs' -T 600 -q args='/test:Advertising' -vvv
Connecting to: https://192.168.1.1:5693/api/plugins/check_ad.vbs/?token=xxxxxxxxxxxxxxx&check=1&args=%2Ftest%3AAdvertising
File returned contained:
{"returncode": 0, "stdout": "OK - Advertising: OK.", "cmd": "cscript C:\\Program Files\\Nagios\\NCPA\\plugins\\check_ad.vbs /test:Advertising //NoLogo"}
OK - Advertising: OK.
The services I'm trying to check are working and If I run the script without argument it will work OK. I'm starting to about creating a PowerShell script that acts as wrapper
User avatar
lgute
Posts: 236
Joined: Mon Apr 06, 2020 2:49 pm

Re: Problem with plugins and arguments with special characters

Post by lgute »

Hi @sgomeztd,

Thanks for reaching out.

What you want to do with non-NCPA plugins is to put all the arguments for the plugin into -q 'args=<all the arguments>'.

For instance, a plugin I use for NCPA looks like this on the command line (remote machine).

Code: Select all

/usr/local/ncpa/plugins/check_myplugin.sh -m daemonsets -H https://192.168.58.140:6443 -t /usr/local/ncpa/etc/58-140-K3s.serviceaccount.token
When I call it through NCPA, the "plugin" specific arguments go in -q 'args=<all the arguments>' like this...

Code: Select all

-q 'args=-m daemonsets -H https://192.168.58.140:6443 -t /usr/local/ncpa/etc/58-140-K3s.serviceaccount.token'
Then to run it through check_ncpa looks like this...

Code: Select all

/usr/local/nagios/libecex/check_ncpa.py -H 192.168.58.140 -t 'xxxxxxxxx' -P 5693 -M 'plugins/check_myplugin.sh' -q 'args=-m daemonsets -H https://192.168.58.140:6443 -t /usr/local/ncpa/etc/58-140-K3s.serviceaccount.token'

Please let us know if you have any other questions or concerns.

-Laura
Post Reply