I have created a http xml/rest sensor to receive some data from a rest api, the setup is below:
URL: https://<appliance>/api/reports/status/
XML Node: 99142989543d4e6fbe5b8acffa5766eb/status
HTTP Headers: CMD_TOKEN:token
When this sensor scans it always reports the last message as 'Process is terminated due to StackOverflowException'
Can anyone advise what I'm doing wrong?
Article Comments
Hi, the new XMLValue program seems to work, however I'm having some trouble extracting the node that I require. The API returns a JSON string, in the format:
{ "99142989543d4e6fbe5b8acffa5766eb":{ "tags":[ ], "shadowprotect":{ "status": "queued" }, "name":"Test", "machine_details":{ }, "imagemanager":{ }, "timezone":3600, "org":"Default Organization", "status":"ok", "lost_contact":0 } }
When I try and get the status node using -n=99142989543d4e6fbe5b8acffa5766eb/status I get an error 'Expression must evaluate to a node-set.' If i set -n=status it returns the value of a node called status that is inside the shadowprotect object, and not the status value that is inside the 99142989543d4e6fbe5b8acffa5766eb object.
Could you tell me the correct way to format the -n= parameter to get the required node?
Thanks!
Aug, 2017 - Permalink
You're after this node "status": "queued", right? Try it like this in the sensor's settings:
99142989543d4e6fbe5b8acffa5766eb/shadowprotect/status
Kind regards,
Erhard
Aug, 2017 - Permalink
Hi,
I'm actually after the node "status":"ok" which I thought should be 99142989543d4e6fbe5b8acffa5766eb/status but this gives an error of 'Expression must evaluate to a node-set.'
For testing purposes I have tried the version that you provided, that is also giving the same error: 'Expression must evaluate to a node-set.'
Is there anyway to fix this?
Aug, 2017 - Permalink
Hello again,
It appears to be a bug, the responsible is currently on vacation, so I don't have a quick fix right now. In the current Preview Version of PRTG is new REST Custom BETA sensor included. You can switch Auto-Update to Preview Channel, install it and use the new sensor then. It should work with this one.
Kind regards,
Erhard
Aug, 2017 - Permalink
Hello again,
The problem here is that the JSON is converted to XML before processing. XML node names are not allowed to start with a number, causing an invalid xml, which is what happened here.
Please find here another version for testing, which you can use to replace the existing executable in PRTG's installation path, subfolder "Sensor System".
Kind regards,
Erhard
Sep, 2017 - Permalink
Hi, the newest version of XMLValue.exe works much better, however, it might be better if instead of giving a response as:
0:Node 99142989543d4e6fbe5b8acffa5766eb/status holds value ok.
Which shows up in PRTG as a message of 'Node 99142989543d4e6fbe5b8acffa5766eb/status holds value ok.' and a value of 0
It would be slightly nicer if it would just return the response as ok (or whatever that value at that node actually is)
This is only a minor inconvenience and can be worked around. Thanks for the help!
Sep, 2017 - Permalink
Thank you, shogan, I will address your feedback accordingly.
Kind regards,
Erhard
Sep, 2017 - Permalink
Hello shogan,
Feedback from the dev was that he's a bit reluctant in changing the output as that might affect other users also. Meaning it changes the behavior to something that might pose a problem for existing users, when the output is suddenly handled differently.
Kind regards,
Erhard
Sep, 2017 - Permalink
Hello there,
In PRTG's installation path, subfolder "Sensor System" you find "XMLValue.exe". Please backup the file and replace the original then with this one: http://download3.paessler.com/beta/XMLValue.exe.zip
Does it work then? Also run the executable from command prompt, it will show you which parameters you can pass along and run it then with parameters from commandline to see what you get there.
Kind regards,
Erhard
Aug, 2017 - Permalink