New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


EXE/XML Custom sensor Screenshot with PhantomJS

Votes:

0

Your Vote:

Up

Down

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 by  bciboci (0) 1

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



6 Replies

Votes:

0

Your Vote:

Up

Down

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

Your Vote:

Up

Down

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 by  bciboci (0) 1

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



Votes:

0

Your Vote:

Up

Down

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

Your Vote:

Up

Down

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 by  bciboci (0) 1



Votes:

0

Your Vote:

Up

Down

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

Your Vote:

Up

Down

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 by  bciboci (0) 1



Please log in or register to enter your reply.


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.