prom_pi_temp.py: expose Raspberry Pi temperatures to Prometheus
This little script grabs Raspberry Pi CPU and GPU temperatures and stores them in a text file formatted for node_exporter, where Prometheus can scrape them.
Usage
- Install node_exporter and enable the textfile collector.
- Install
prom_pi_temp.py
. - Setup a cron job to run
prom_pi_temp.py
and save the output to a text file in the directory you configured above. - Confirm you can see the temperature metrics.
node_exporter --collector.textfile.directory=/var/run/node_exporter_textfile
echo '* * * * * /usr/local/bin/prom_pi_temp.py > /var/run/node_exporter_textfiles/temps.prom' > /etc/cron.d/prom_pi_temp.cron
curl -s localhost:9100/metrics | grep node_temp
Improvements welcome!!