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]"


Article Comments

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 support@paessler.com


Dec, 2021 - Permalink