Hi,
I am using a docker container of LibreNMS to monitor several devices in my network, including a Raspberry Pi with a DHT22 sensor (temperature & humidity) connected to it.
On the Raspberry Pi, SNMP is installed and configured, as described in “Applications - LibreNMS Docs” and in “Check_MK Setup - LibreNMS Docs”.
The expected values are diaplay in LibreNMS:
Regarding the connected DHT22 sensor, I was able to include the values temperature & humidity values from the sensor into the SNMP response using following configuration in “snmp.conf” and using following scripts:
/etc/snmp/snmpd.conf
pass .1.3.6.1.2.1.25.1.8.2 /bin/sh /usr/local/bin/DHT-temp-snmp
pass .1.3.6.1.2.1.25.1.8.1 /bin/sh /usr/local/bin/DHT-hum-snmp
extend temp /bin/sh /usr/local/bin/DHT-temp-snmp -g
extend hum /bin/sh /usr/local/bin/DHT-hum-snmp -g
/usr/local/bin/DHT-temp-snmp (same approach for “DHT-hum-snmp”)
#!/bin/bash
if [ “$1” = “-g” ]
then
python3 /usr/local/bin/DHT-temp-snmp.py
fi
exit 0
/usr/local/bin/DHT-temp-snmp.py (same approach for “DHT-hum-snmp.py”)
#!/usr/bin/python3
import sys
import Adafruit_DHT
pin = “4”;
sensor = Adafruit_DHT.DHT22;
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if humidity is not None and temperature is not None:
_ print(‘.1.3.6.1.2.1.25.1.8.2’)_
_ print(‘gauge’)_
_ print(‘{0:0.1f}’.format(temperature))_
else:
_ print(‘Failed to get reading. Try again!’)_
_ sys.exit(1)_
This part is working fine and the SNMP response in LibreNMS is:
.1.3.6.1.4.1.8072.1.3.2.3.1.1.3.104.117.109 = STRING: “.1.3.6.1.2.1.25.1.8.1”
.1.3.6.1.4.1.8072.1.3.2.3.1.1.4.116.101.109.112 = STRING: “.1.3.6.1.2.1.25.1.8.2”
.1.3.6.1.4.1.8072.1.3.2.2.1.2.3.104.117.109 = STRING: “/bin/sh”
.1.3.6.1.4.1.8072.1.3.2.2.1.2.4.116.101.109.112 = STRING: “/bin/sh”
.1.3.6.1.4.1.8072.1.3.2.2.1.3.3.104.117.109 = STRING: “/usr/local/bin/DHT-hum-snmp -g”
.1.3.6.1.4.1.8072.1.3.2.2.1.3.4.116.101.109.112 = STRING: “/usr/local/bin/DHT-temp-snmp -g”
.1.3.6.1.4.1.8072.1.3.2.4.1.2.3.104.117.109.1 = STRING: “.1.3.6.1.2.1.25.1.8.1”
.1.3.6.1.4.1.8072.1.3.2.4.1.2.3.104.117.109.2 = STRING: “gauge”
.1.3.6.1.4.1.8072.1.3.2.4.1.2.3.104.117.109.3 = STRING: “41.2”
.1.3.6.1.4.1.8072.1.3.2.4.1.2.4.116.101.109.112.1 = STRING: “.1.3.6.1.2.1.25.1.8.2”
.1.3.6.1.4.1.8072.1.3.2.4.1.2.4.116.101.109.112.2 = STRING: “gauge”
.1.3.6.1.4.1.8072.1.3.2.4.1.2.4.116.101.109.112.3 = STRING: “28.3”
But I did not find a way to display those values in the “Overview” section of this device in LibreNMS. Does anyone knows how to configure LibreNMS in order to have those values correctly displayed?
Thanks in advance for your help and kind regards.