Git Product home page Git Product logo

pi-temp's Introduction

pi-temp

Build Status License

Small utility to export the CPU temperature of a Raspberry Pi as Prometheus metric.

Usage

# Cross compile and upload to your raspberry:
$ GOARCH=arm64 go build && scp pi-temp raspberry:/usr/local/bin/pi-temp
pi-temp                                                    100% 9619KB   9.4MB/s   00:01

# Log into your Pi:
$ ssh raspberry

# Helpful help output is helpful:
Usage of pi-temp:
  -addr string
    	The address to listen on for HTTP requests. (default ":8080")
  -debug
    	Enable debug output.
  -file string
    	Path to the thermal zone file. (default "/sys/class/thermal/thermal_zone0/temp")
  -interval duration
    	The interval at which the temperature is checked. (default 10s)

# Run it:
$ pi-temp -debug
Checking temperature every 10s from "/sys/class/thermal/thermal_zone0/temp"
CPU temperature: 55.306°C
CPU temperature: 54.768°C
CPU temperature: 54.768°C
CPU temperature: 54.768°C
…

Why?

Node exporter apparently doesn't track this metric and this was super easy to do by myself.

Systemd

I use the pi-temp.service file to install the cross compiled binary as simple systemd service into my Raspberry Pi like this:

# Upload systemd unit file:
$ scp pi-temp.service raspberry:/etc/systemd/system/pi-temp.service

# Log into your Pi:
$ ssh raspberry

# Enable service to start on boot:
$ systemctl enable pi-temp.service

# Start pi-temp service now:
$ systemctl start pi-temp

# Check its running:
$ systemctl status pi-temp
● pi-temp.service - Prometheus Temperature Monitor
   Loaded: loaded (/etc/systemd/system/pi-temp.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2018-08-12 23:20:18 CEST; 1s ago
 Main PID: 7886 (pi-temp)
    Tasks: 7 (limit: 1053)
   Memory: 1.3M
   CGroup: /system.slice/pi-temp.service
           └─7886 /usr/local/bin/pi-temp -interval=10s -addr=:9101

Aug 12 23:24:49 rasputin systemd[1]: Started Prometheus Temperature Monitor.
Aug 12 23:24:49 rasputin pi-temp[7953]: Starting pi-temp web server at ":9101"
Aug 12 23:24:49 rasputin pi-temp[7953]: If you want to see more verbose log run with -debug

License

© Friedrich Große 2018, distributed under MIT License.

pi-temp's People

Contributors

fgrosse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jsidhu ryane

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.