NCPA API Endpoint URL Arguments that Contain Forward Slash
Posted: Thu Jun 08, 2017 10:54 am
G ' Day Nagios XI Customer Support,
I have come up against a wall and cannot seem to figure out how to go over, under or around it.
Synopsis: Build a Powershell script that accepts three arguments registry path, name of key and expected value
i.e.
./check_registry_value.ps1 [registry path] [registry key] [expected value]
./check_registry_value.ps1 HKLM:\HARDWARE\DESCRIPTION\System\BIOS BIOSReleaseDate "11/01/2015"
OK: Value of 11/01/2015 is as expected value. Works... Taste great! Less filing!
So now I transfer the functionality into the NCPA framework.
Testing first from the NCPA web server API tab.
To pass arguments into the plugins API you can specify all three arguments in one available field or you can specify three fields each containing their own argument...good so far.
To pass special characters like "\" backslash into the url it is required to use %5C for argument one...good so far
Which results in the following text for argument 1: HKLM%3A%5CHARDWARE%5CDESCRIPTION%5CSystem%5CBIOS
Next add the second argument which is simply straight text which is no issue...again good so far
Which results in the following text for argument 2: BIOSReleaseDate
Lastly I need to pass the expected date as defined in the registry field for the last argument...this is where things went bad!
Resulting in argument 3 being passed as: 11%2F01%2F2016 <-- I have tried every way I can think of to get this to work.
I have attempted to pass all kinds on urlencode combinations to include escape characters and for the life of me I cannot seem to get the argument to include forward slashes. I understand that the url that is being passed to the NCPA web server uses forward slashes as it delimiter for passing arguments but why it will not accept %2F as part of the argument and ignore it as part of the url can only mean its not being considered in the code. Of course if the last argument contains spaces %20 or back slash %5C it processes the URL fine and functions as expected...only the forward slash %2F appears to not usable.
i.e.
https://dg0123-ibm-6029:3181/api/plugin ... F01%2F2016
{ "returncode": 2, "stdout": "CRITICAL: Value of 11/01/2016 does not equal the expected value of 11." }
If anyone has experienced this and was able to resolve I would be greatly appreciative as I have spent much time in trying to solve to no avail.
Perhaps there is configuration within the ncpa.cfg to control the ability to allow slashes in the url???
Thanks for your help,
Danny
I have come up against a wall and cannot seem to figure out how to go over, under or around it.
Synopsis: Build a Powershell script that accepts three arguments registry path, name of key and expected value
i.e.
./check_registry_value.ps1 [registry path] [registry key] [expected value]
./check_registry_value.ps1 HKLM:\HARDWARE\DESCRIPTION\System\BIOS BIOSReleaseDate "11/01/2015"
OK: Value of 11/01/2015 is as expected value. Works... Taste great! Less filing!
So now I transfer the functionality into the NCPA framework.
Testing first from the NCPA web server API tab.
To pass arguments into the plugins API you can specify all three arguments in one available field or you can specify three fields each containing their own argument...good so far.
To pass special characters like "\" backslash into the url it is required to use %5C for argument one...good so far
Which results in the following text for argument 1: HKLM%3A%5CHARDWARE%5CDESCRIPTION%5CSystem%5CBIOS
Next add the second argument which is simply straight text which is no issue...again good so far
Which results in the following text for argument 2: BIOSReleaseDate
Lastly I need to pass the expected date as defined in the registry field for the last argument...this is where things went bad!
Resulting in argument 3 being passed as: 11%2F01%2F2016 <-- I have tried every way I can think of to get this to work.
I have attempted to pass all kinds on urlencode combinations to include escape characters and for the life of me I cannot seem to get the argument to include forward slashes. I understand that the url that is being passed to the NCPA web server uses forward slashes as it delimiter for passing arguments but why it will not accept %2F as part of the argument and ignore it as part of the url can only mean its not being considered in the code. Of course if the last argument contains spaces %20 or back slash %5C it processes the URL fine and functions as expected...only the forward slash %2F appears to not usable.
i.e.
https://dg0123-ibm-6029:3181/api/plugin ... F01%2F2016
{ "returncode": 2, "stdout": "CRITICAL: Value of 11/01/2016 does not equal the expected value of 11." }
If anyone has experienced this and was able to resolve I would be greatly appreciative as I have spent much time in trying to solve to no avail.
Perhaps there is configuration within the ncpa.cfg to control the ability to allow slashes in the url???
Thanks for your help,
Danny