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
Add comment