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

Custom Parameters in Python Script

Votes:

0

Hello,

I'm currently evaluating PRTG and I started writing some Python scripts for scanning Log-Files.

It basically worked, but i want to enter an Addiotional Parameter in the Sensor's Settings:

LogFilePath='C:/Temp/'

which i want to use in Python via

data = json.loads(sys.argv[1]) path = data['LogFilePath']

I'm rather new to python, coming from .net/ WPF and I believe I'm somehow wrong with the syntax.

I would truely appreciate a hint in the right direction.

Thanks! Nikolaus

custom-sensor parameters python

Created on Nov 8, 2017 4:59:05 PM



2 Replies

Accepted Answer

Votes:

0

Hi there,

The Python parameters are passed to the script via the "params"-Parameter. This will look like this:

Data['params'].asString := 'myParam=myValue’;

To split them into an array you can use the following sample code:

data = json.loads(sys.argv[1])
prtg_perams = data['params']

perams = dict(x.split('=') for x in prtg_perams.split(','))

The parameters will be available in the "perams"-array.

Example to use them:

print(perams['myParam'])

Best regards.

Created on Nov 9, 2017 3:02:56 PM by  Dariusz Gorka [Paessler Support]

Last change on Jul 31, 2020 8:29:29 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Thank You!

Created on Nov 10, 2017 3:40:17 PM




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.