Balluff + PRTG +IoT

balluff.PNG

 

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

https://blog.paessler.com/how-to-monitor-server-room-temperature-with-prtg-on-a-budget

Great, so how can we get the data? PRTG has a nice builtin python plugin system.

ports.PNG

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\
python.exe get-pip.py
cd Scripts
pip install simplejson

So now my hacked together plugin looks like this

python.PNG

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

dials.PNG

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: