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

Create Python Script...



Hello, i´am new in this python script thing, and i´am trying to show the name of my cluster owner with the following script.

I dont know how to return the information.... Does anyone can help me?

  1. -*- coding: UTF-8 -*- import os import json

def func_cluster(): os.system(r'C:\Users\victor.salomao\Downloads\PSTools\PsExec
mqprod01 -u username -p password cmd.exe /v /c echo ^%computername^% > ClusterOwner.log')

arquivo = open('ClusterOwner.log') cluster_owner = arquivo.read()


estrutura = {"prtg": {"result": [{"channel": "First channel", "value": ""}]}} estrutura['prtg']['result'][0]['value'] = cluster_owner

with open('data.json', 'w') as arquivo: json.dump(estrutura, arquivo)

with open('data.json', 'r') as f: data = json.load(f)

return data


custom-sensor python script

Created on May 26, 2017 1:55:51 PM

3 Replies



Hello Giacometti,

Thank you very much for your knowledge base post.

Please check either the exemplary expected standard output format for XML or JSON which can be found in PRTG under Setup | PRTG API | Custom Sensors | ADVANCED SCRIPT AND HTTP DATA SENSORS | XML/JSON Return Format.
Alternatively, please check the example Python file (sensore_example.py) located in C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\python on your PRTG Core Server.

Best regards,

Created on May 29, 2017 11:13:17 AM by  Sebastian Kniege [Paessler Support]



I got it!!!

Do you know if PRTG stores the variables of script in memory? i changed some values and still showing the old ones.

i already excluded the sensor and added a new one but nothing changed.

Created on May 29, 2017 3:28:13 PM



Hello Giacometti,

well done! No, results are not cached in the memory. Please enable Write EXE result to disk in the sensor settings. This function will store the last result received from the script with the file name "Result of Sensor [ID].txt" to the "Logs (Sensors)" directory (on the Master node, if in a cluster). This is for debugging purposes. The file will be overridden with each scanning interval.
Please check the output in this log file, I assume that it matches with the values shown in PRTG.

Best regards,

Created on May 30, 2017 6:37:38 AM by  Sebastian Kniege [Paessler Support]

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.