Hi,
I have a problem with my Custom sensor. I have to go to the Webpage of our company and take a screenshot. But I get the following error:
XML: Structural error in xml file, 1 open items. -- JSON: Das zurückgelieferte JSON entspricht nicht der erwarteten Struktur (Invalid JSON.). (Code: PE231)
I don't exactly understand why there is an error, because an other sensor that I made almost the same way works just fine. And the second question is where does PRTG saves my Screenshots?
Here is the code that I have:
page.onResourceReceived = function(response) { // Taking a screenshot if(response.url === ''some URL address") { page.render("Screenshot.jpg"); }; // Status codes if(response.status >= 200 && response.status < 300) { errorVar = 0; errorText = "OK"; }; if(response.status >= 300 && response.status < 400) { errorVar = 1; errorText = "Warning"; }; if(response.status >= 400 && response.status < 500) { errorVar = 2; errorText = "Client error"; }; if(response.status >= 500 && response.status < 600) { errorVar = 3; errorText = "Server error"; }; var error = errorVar; var text = errorText; // Defining the channels object = { prtg: { error: error, text: text, result:[ { channel: "Screenshot", value: 0 } ] } }; object = JSON.stringify(object) console.log(object) phantom.exit(); }
So the response.status part of the code is just to see if there is an error and if the webpage "works" or not. The channel, well, I don't actually need it, but I put it anyway. As I did this normally in the command propt (without implementing it on the PRTG), it worked just fine (but the code was different, i.e. I didn't needed the "PRTG part".
Thanks and kind regards
Benjamin
Article Comments
Hi,
this is in the log files:
{"prtg":{"error":1,"text":"Warning","result":[{"channel":"Screenshot","value":0}]}} {"prtg":{"error":1,"text":"Warning","result":[{"channel":"Screenshot","value":0}]}} Fatal Windows exception, code 0xc0000005. PhantomJS has crashed. Please read the bug reporting guide at <http://phantomjs.org/bug-reporting.html> and file a bug report.
Best regards, Benjamin
May, 2019 - Permalink
Hi there,
I assume that due to this line:
<http://phantomjs.org/bug-reporting.html> and file a bug report. |
PRTG assumes that there is an XML result coming. Is it possible for you to suppress this error message?
Best regards.
May, 2019 - Permalink
Hi,
I think it might could be that, when I use in PhantomJS the function "page.onResourceReceived", it always (for example) prints twice the same result. So, for example, if I do it normally in my command prompt, and I want to see the resource url of some webpage, it will always print it twice. Could maybe this be the problem?
Best regards, Benjamin
May, 2019 - Permalink
Hi Benjamin,
I am not sure if the duplicated result causes this, but as mentioned the error that PhantomJS prints might be the cause here. You could add a teststring to the console.log to check if this function is called twice.
Best regards.
May, 2019 - Permalink
Hi,
I must admit that I don't really understand what exactly this error is. I don't know what I should change.
Best regards, Benjamin
May, 2019 - Permalink
Hi there,
Please activate the "Write EXE result to disk" option in the sensor's settings and post the log files (Result of Sensor XXX.Data.txt and Result of Sensor XXX.txt) located on the corresponding probe under "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)".
Best regards.
Apr, 2019 - Permalink