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

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

Trying to implement a Python Script Advanced Sensor but I get (code: PE233) -- (code: PE231)

Votes:

0

Your Vote:

Up

Down

Here is my code:

if __name__ == "__main__":
    try:
          #Code to generate the dictionary that I will not put in the question otherwise it gets too long
        dictionary = {"Record_letti": temp2[11], "Record_aggiunti": temp2[17], "Record_modificati": temp2[23], "Record_eliminati": temp2[29], "Record_scartati": temp2[35]} }
        #print(dictionary)
        #create a prtg sensor and add the channel data
        sensor = CustomSensorResult(text="This sensor runs a log reader")
        sensor.add_channel(name='Record Letti',unit='Count',value=dictionary["Record_letti"])
        sensor.add_channel(name='Record Aggiunti',unit='Count',value=dictionary["Record_aggiunti"])
        sensor.add_channel(name='Record Modificati',unit='Count',value=dictionary["Record_modificati"])
        sensor.add_channel(name='Record Eliminati',unit='Count',value=dictionary["Record_eliminati"])
        sensor.add_channel(name='Record Scartati',unit='Count',value=dictionary["Record_scartati"])
        #send the sensor data back to the prtg process in json #format
        print(sensor.json_result)
        #create a prtg sensor and add the channel data
        sensor = CustomSensorResult(text="This sensor runs a log reader")
        print(json.dumps(dictionary, indent = 4))
    except Exception as e:
        sensor = CustomSensorResult(text="Python Script execution error")
        sensor.error = "Python Script execution error: " % str(e)
        print(sensor.json_result)

The log says "Script Output (UTF8 Encoding): File "C:\Program Files (x86)\PRTG Network Monitor\custom sensors\python\FiPlanLogReader.py", line 1[CR][LF] {\rtf1\ansi\ansicpg1252\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Calibri;}}[CR][LF] ^[CR][LF]SyntaxError: unexpected character after line continuation character[CR][LF]"

advanced-sensor json python xml

Created on Dec 7, 2021 1:56:05 PM by  mmone (0) 1

Last change on Dec 7, 2021 3:01:09 PM by  Felix Wiesneth [Paessler Support]



1 Reply

Votes:

0

Your Vote:

Up

Down

Hello, can you mention what is the PRTG version you are using? We would need to see the debug log of this sensor. Please go to the settings tab of the sensor and under debug option please activate the "Write Sensor result to disk" option in the sensor settings, wait for a couple of scaning intervals so the debug creates the result files, and forward us the log files (Named result of Sensor XXX.Data.txt and Result of Sensor XXX.txt) located on the corresponding probe.

PRTG will store the files in \Logs\sensors subfolder of the PRTG data directory on the probe system. To make sure what is the folder you are using for the PRTG data, open the 'PRTG Administration tool' program in the core/probe and go to the Core server tab, there you can see the location.

We also need a screenshof ot the sensor overview tab, settings tab and Log tab.

It would be better to send that information on a ticket to [email protected]

Created on Dec 10, 2021 9:25:15 PM by  Jonathan Mena [Paessler Technical Support]



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.