I’m using a raspberry pi with XBMC as a mediaplayer. As I didn’t want to have a lot of trouble maintaining it, I decided to try OpenELEC. It works fine, but it’s really limited to only the media-related parts.
I wanted to know how much the temperature changes when using my raspberry pi and I already had a working cacti-server in my LAN. But what would be the best way to read the temperature from the pi without pushing too many binaries onto the system?
The answer is „socat“ – and of course, the binary is NOT part of the OpenELEC-distribution. But I was able to compile the socat as a static binary on another raspberry pi, which was runnning raspbian.
./configure LDFLAGS="-static" make
Copy the resulting binary
socat to the OpenELEC-raspberry. If you can’t create the binary yourself, you can download it from here:
socat: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 2.6.26, BuildID[sha1]=8ca6f5b38a7836cefe0721295d946dd9f90fb98e, not stripped
Put the socat in a new directory called
Add the following two files in the same directory
#!/bin/bash /storage/tempservice/socat -T 1 -d -d tcp-l:9888,reuseaddr,fork,crlf system:"/storage/tempservice/t.sh"
#!/bin/bash cat /sys/class/thermal/thermal_zone0/temp
socat-service.sh will later start the service, while
t.sh reads the temperature itself.
To make sure that the service is started on startup, we introduce a new system service in
system.d: Change to the directory
/storage/.config/system.d and add the following file:
[Unit] Description=SocatTempServer [Service] Type=simple ExecStart=/storage/tempservice/socat-service.sh [Install] WantedBy=multi-user.target
And enable the service:
systemctl enable socat.service
Reboot and test from the other system in the LAN whether we can read the temperature:
nc PI-IP 9888 | tr -d '\r'
Now all you have to do is include the result in a cacti script and show the result.
Here’s what it may look like: