Skip to content

pascalschoener/raspbi-temperature-exporter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prometheus Temperature exporter for raspberry pi

Build Status

Prometheus Endpoint, written in Python to read DHT11 1wire sensor and exposes temperature values as a prometheus metric.

Prerequisites

Make sure, you have the required kernel modules loaded. To do so, follow these steps:

$ sudo modprobe w1-gpio
$ sudo modprobe w1-therm 
$ sudo echo "dtoverlay=w1-gpio" >> /boot/config.txt #to enable 1-wire config and persist after reboot
$ lsmod #check if modules are loaded correctly
$ sudo reboot

After your pi has been rebooted, check if you can list the attached 1-wire devices

$ ls /sys/bus/w1/devices/

Implementation

Have a look at the sourcecode for details. Generally, you'll have to download and import the required python libraries. Refer to the official documentation on how to implement a prometheus exporter: https://github.com/prometheus/client_python.

Dockerrization

I've used hypriot os with a RaspberryPi 3B+. It works on a Raspberry Pi 2 too, although docker builds might take some time, so be calm to your Pi.

Building and running

You can run the exporter either via python itself or in a docker container. The required commands for running it via python are also in the supplied Makefile. For docker use:

$ docker build -t raspbi-temperature-exporter:arm32v6 -f Dockerfile .
$ docker run -it -e EXPORTER_PORT=9103 -p 9103:9103 raspbi-temperature-exporter:arm32v6

You can also download it from docker hub via docker pull lukasbahr/raspbi-temperature-exporter:arm32v6

Open ToDo's

  • [OPEN] Add CI/CD Support
  • [OPEN] Add unit tests
  • [OPEN] use buildx to create the proper image
  • [OPEN] Add health metric, error metric, scrape interval, general information about exporter etc.

About

A prometheus exporter for 1-wire temperature sensors on raspberry pi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 59.2%
  • Makefile 31.4%
  • Dockerfile 9.4%