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
Article Comments
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.
Nov, 2017 - Permalink
Hi there,
The Python parameters are passed to the script via the "params"-Parameter. This will look like this:
To split them into an array you can use the following sample code:
The parameters will be available in the "perams"-array.
Example to use them:
Best regards.
Nov, 2017 - Permalink