So the BNI EIP-508-105-Z015 (IO-LINK) has a nifty way of exposing the sensor data through some json provided on an internal web page. The article I read had this as webaddress/dprop.jsn
but in my version it ended up being http://webaddress/ports.jsn (go figure?)
I had previously read some PRTG articles where they discuss some simple IoT
Great, so how can we get the data? PRTG has a nice builtin python plugin system.
So, we get to go searching for the python ‘custom sensors’ directory. It happens to be
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\python on my box.
So, I ran into a weird wrinkle. I wanted to read the json coming off the website, modify it and then return it through the plugin. Anytime I read some json data I think the plugin would think I was done and trying to return. So, my quick hack around this was to just use simplejson for parsing the json from the /ports.jsn and then json for the ‘result’
To install simplejson into the prtg python environment do this
Download https://bootstrap.pypa.io/get-pip.py into PRTGs python directory
cd C:\Program Files (x86)\PRTG Network Monitor\Python34\
pip install simplejson
So now my hacked together plugin looks like this
Basically, read in the json from the Balluff using simplejson, iterate through the ports, split out the hex values, convert them to a temperature (in this case).
Then finally, add the device and sensor to PRTG