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