Raspberry Pi: Temperature & Humidity Sensor (DHT22) - How to display values in LibreNMS


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:


pass . /bin/sh /usr/local/bin/DHT-temp-snmp
pass . /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”)

if [ “$1” = “-g” ]
python3 /usr/local/bin/DHT-temp-snmp.py
exit 0

/usr/local/bin/DHT-temp-snmp.py (same approach for “DHT-hum-snmp.py”)

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(‘.’)_
_ print(‘gauge’)_
_ print(‘{0:0.1f}’.format(temperature))_
_ print(‘Failed to get reading. Try again!’)_
_ sys.exit(1)_

This part is working fine and the SNMP response in LibreNMS is:

. = STRING: “.”
. = STRING: “.”
. = STRING: “/bin/sh”
. = STRING: “/bin/sh”
. = STRING: “/usr/local/bin/DHT-hum-snmp -g”
. = STRING: “/usr/local/bin/DHT-temp-snmp -g”
. = STRING: “.”
. = STRING: “gauge”
. = STRING: “41.2”
. = STRING: “.”
. = STRING: “gauge”
. = 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.

Does anyone have a similar configuration and/or know how to set it up?
Thanks and kind regards.


You need to define your own operating system in LibreNMS, then use one of your own OIDs as a way for LibreNMS to recognize it from a standard Raspberry device.
When done, you can create include/definitions/discovery/yourownos.yaml which will graph any sensor you like. look at the other yaml files in that directory, search for sensors of temperature and humidity type. You also need to write your own mibfile to do a proper YAML discovery.

Hi PipoCanaja,

Thanks a lot for your answer!

Do you perhaps have a few details (or better a tutorial / links) on how to setup this up?
I am a newbie for this kind of configuration in LibreNMS…

Thanks in advance and kind regards.

The documentation is here :

You can come back here to ask questions of course. Discord is also a good way to get some help in the Devel chan.

Hi crivchri,

Is this coding suitable for DHT11 sensor ? Seeking your advise. Thanks