What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

EXE/XML Custom sensor Screenshot with PhantomJS

Votes:

0

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

custom-sensor prtg screenshots

Created on Apr 26, 2019 11:13:58 AM

Last change on Apr 26, 2019 12:05:11 PM by  Sven Roggenhofer [Paessler Technical Support]



6 Replies

Votes:

0

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.

Created on Apr 29, 2019 10:34:11 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

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

Created on May 2, 2019 8:30:13 AM

Last change on May 2, 2019 12:43:28 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

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.

Created on May 2, 2019 12:44:47 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

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

Created on May 2, 2019 12:54:27 PM



Votes:

0

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.

Created on May 2, 2019 2:10:26 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

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

Created on May 3, 2019 7:13:54 AM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.