Search the Community
Showing results for tags 'snmp datasources'.
Found 1 result
I setup a Raspberry Pi with a Sense Hat so I can track the internal Temperature and Humidity of my living room in Logic Monitor. The data is accessable from running a python script on the Raspberry Pi itself, but I didn't want to install a collector on that device. The solution I decided on was using Extend Snmp. This guide can be used as a template for similar logicMonitor task. I used Steve Francis's "How to teach an old snmpd new tricks" Blog post as a guide. The first step was creating the python script. This script reads the humidity and temperature readings from the Sense Hat, rounds the results and prints the output to STDOUT. from sense_hat import SenseHat sense = SenseHat() sense.clear() hum = sense.get_humidity() hum = round(hum,1) hum= str(hum) print hum temp = sense.get_temperature() temp = ((temp/5)*9)+32 temp = round(temp,1) temp= str(temp) print temp Next I added a line to the to the /etc/snmp/snmpd.conf file to extend SNMP. It basically tells the SNMP daemon to run the python script and include the output in the SNMP extend OIDs. extend lm-temp /usr/bin/python2.7 /home/pi/scripts/weather/tempature.py After a restart of the SNMP Daemon, you can see the actual output by walking .188.8.131.52.4.1.8072.1.3.2 $ !snmpwalk 10.73.42.116 .184.108.40.206.4.1.8072.1.3.2 Walking OID .220.127.116.11.4.1.8072.1.3.2 from host=10.73.42.116, version=v2c, port=161, timeout=3 seconds: 1.0 => 1 18.104.22.168.22.214.171.124.101.109.112 => /usr/bin/python2.7 126.96.36.199.188.8.131.52.101.109.112 => 4 184.108.40.206.220.127.116.11.101.109.112 => 1 18.104.22.168.22.214.171.124.101.109.112 => /home/pi/scripts/weather/tempature.py 126.96.36.199.188.8.131.52.101.109.112 => 184.108.40.206.220.127.116.11.101.109.112 => 5 18.104.22.168.22.214.171.124.101.109.112 => 1 126.96.36.199.188.8.131.52.101.109.112 => 1 184.108.40.206.220.127.116.11.101.109.112 => 47.3 18.104.22.168.22.214.171.124.101.109.112 => 47.3 79.0 126.96.36.199.188.8.131.52.101.109.112 => 2 184.108.40.206.220.127.116.11.101.109.112 => 0 18.104.22.168.22.214.171.124.126.96.36.199 => 47.3 188.8.131.52.184.108.40.206.220.127.116.11 => 79.0 Those last two OIDs is the humidity and Temperature output from my python script. Putting everything together. The OID for the humidity and temperature reported by my Raspberry Pi are .18.104.22.168.4.1.8072.1.3.2.22.214.171.124.126.96.36.199.188.8.131.52 and .184.108.40.206.4.1.8072.1.3.2.220.127.116.11.18.104.22.168.22.214.171.124 respectively and can be included into a SNMP datasource as shown below I did run into some trouble with the SNMP daemon accessing the hardware. Daemons usually run under self-named unprivileged users and I had to add the snmp user to the groups input and gpio so the daemon had access to the hardware. This was easy enough with the command "sudo addgroup snmp gpio" and "sudo addgroup snmp input".