So you wrote a nice custom script to monitor you Next Cool Thing, and it doesn't work. Not only does it not work, you can't figure out what is wrong with it.
So how do you solve it?
First, turn on sensor debugging.
Go to the sensor in question, then Settings. Scroll down until you find this bit.
Turn that on.
Got that? Good.
Now the interesting part. Where are my readings?
C:\program data\Paessler\PRTG Network Monitor\Logs (Sensors)\
So there you have it.
Kind of.
You get two files for every sensor. One file indicates all the stuff that was sent to the sensor via PRTG. That's the file with the name "Result of Sensor XXXX.Data.txt"
The other file is the output after the script has been run. That's "Result of Sensor XXXX.log"
From there, it's time to go read that second log file and try to figure out what the problem might be. The big problem I have with troubleshooting Python scripts is the lack of an Idle interpreter in the default installation of PRTG.
That's survivable. Notepad is there. It's just more annoying.
The second part of reference is that the interesting bits about what failed is generally at the very end of the script output.
Is this the perfect debugging scenario? No. But it does provide the information you need to figure out why your script isn't working.
You did write the script on a machine with better debugging utilities to try and make a good proof of concept, right?
So best practice in my eyes: write the entire script except the output bits on a separate machine before transferring it to the remote probe and/or primary server.
So... Have fun, and go squash some bugs.
A blog about the things that interest me. Includes random thoughts, Cisco, programming, and business related stuff from convenience store world.
Monday, December 30, 2019
Thursday, December 5, 2019
PRTG: Making Custom Sensors to monitor strange things with Python
#verion 1.0
#last modified 12/2/19
#
#v 1.0 initial revision / prtg integration
#
import sys
import json
import urllib.request
from paepy.ChannelDefinition import CustomSensorResult
if __name__ == "__main__":
location = json.loads(sys.argv[1])
parsed = "http://" + str(location['host']) + "whatever else in the url"
page = urllib.request.urlopen(parsed).read()
#data comes out as binary type.
#convert from binary to normal string
np = page.decode('utf-8')
scrip = np.split('
Subscribe to:
Posts (Atom)