lukasmalkmus / rpi_exporter

A Raspberry Pi CPU temperature exporter.
Apache License 2.0
79 stars 17 forks source link

RPi GPU temperature #5

Closed ruzickap closed 5 years ago

ruzickap commented 5 years ago

Would it be possible to add also the RPi GPU temperature to rpi-exporter ?

RPi GPU temperature can be found by running:

raspi ~ # /opt/vc/bin/vcgencmd measure_temp
temp=55.3'C

Thanks...

lukasmalkmus commented 5 years ago

Will look into it. I'm reading from /sys/class/thermal/thermal_zone0/temp. Is the output any different from running ./opt/vc/bin/vcgencmd measure_temp? I need to set up a Pi to validate this.

You can use this as a quick workaround.

rpi_exporter also supports textfile collection so you could hook that up somehow.

ruzickap commented 5 years ago

Probably I can do some workaround, but I prefer to have it inside the rpi_exporter if possible.

Here is how the commands differs:

raspi ~ # cat /sys/class/thermal/thermal_zone0/temp
55844

raspi ~ # /opt/vc/bin/vcgencmd measure_temp
temp=56.4'C

It's just a feature which can improve the rpi_exporter.

lukasmalkmus commented 5 years ago

Could you check out #7? I didn't have the time to setup a RPi and test this. Could you check out the branch, build and test for me? I won't have time before the weekend.

If you verify, I'll merge and cut a new release.

ruzickap commented 5 years ago

Thank you, but it looks like there are some problems:

raspi1 ~/rpi_exporter # ./rpi_exporter --log.level="debug"
INFO[0000] Starting rpi_exporter(version=, branch=, revision=)  source="rpi_exporter.go:82"
INFO[0000] Build context(go=go1.11.6, user=, date=)      source="rpi_exporter.go:83"
INFO[0000] Listening on:9243                             source="rpi_exporter.go:115"
DEBU[0208] collect query: []                             source="rpi_exporter.go:37"
DEBU[0208] textfile collector succeeded after 0.005354s  source="collector.go:145"
DEBU[0208] cpu collector succeeded after 0.003701s       source="collector.go:145"
ERRO[0208] gpu collector failed after 0.100987s: strconv.ParseFloat: parsing "49.8'C\n": invalid syntax  source="collector.go:142"

You probably forget to remove the 'C from the command output.

lukasmalkmus commented 5 years ago

Yes, had a typo there and used the wrong function. Feel free to try again.

ruzickap commented 5 years ago

Looks like it still doesn't help. I included all the commands I used:

raspi1 ~ # git clone https://github.com/lukasmalkmus/rpi_exporter.git
Cloning into 'rpi_exporter'...
remote: Enumerating objects: 31, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 916 (delta 11), reused 22 (delta 6), pack-reused 885
Receiving objects: 100% (916/916), 1.60 MiB | 474.00 KiB/s, done.
Resolving deltas: 100% (411/411), done.
Checking out files: 100% (503/503), done.

raspi1 ~ # cd rpi_exporter/

raspi1 ~/rpi_exporter # git checkout gpu-temp
Branch 'gpu-temp' set up to track remote branch 'gpu-temp' from 'origin'.
Switched to a new branch 'gpu-temp'

raspi1 ~/rpi_exporter # make
>> checking code style
>> checking license header
>> running check for unused/missing packages in go.mod
GO111MODULE=on go mod tidy
>> running check for unused packages in vendor/
GO111MODULE=on go mod vendor
>> building binaries
GO111MODULE=on /root/go/bin/promu build --prefix /root/rpi_exporter
 >   rpi_exporter
>> running all tests
GO111MODULE=on go test   -mod=vendor ./...
?       github.com/lukasmalkmus/rpi_exporter    [no test files]
?       github.com/lukasmalkmus/rpi_exporter/collector  [no test files]

raspi1 ~/rpi_exporter # ./rpi_exporter --log.level="debug"
INFO[0000] Starting rpi_exporter(version=, branch=, revision=)  source="rpi_exporter.go:82"
INFO[0000] Build context(go=go1.11.6, user=, date=)      source="rpi_exporter.go:83"
INFO[0000] Listening on:9243                             source="rpi_exporter.go:115"
DEBU[0012] collect query: []                             source="rpi_exporter.go:37"
DEBU[0012] cpu collector succeeded after 0.001433s       source="collector.go:145"
DEBU[0012] textfile collector succeeded after 0.034813s  source="collector.go:145"
ERRO[0012] gpu collector failed after 0.081416s: strconv.ParseFloat: parsing "47.1'C\n": invalid syntax  source="collector.go:142"
lukasmalkmus commented 5 years ago

Maybe it was to early for my brain :) Try again. Fixed it. And thanks for your patience :)

ruzickap commented 5 years ago

No worries... Now it's working fine:

raspi1 ~/rpi_exporter # ./rpi_exporter --log.level="debug"
INFO[0000] Starting rpi_exporter(version=, branch=, revision=)  source="rpi_exporter.go:82"
INFO[0000] Build context(go=go1.11.6, user=, date=)      source="rpi_exporter.go:83"
INFO[0000] Listening on:9243                             source="rpi_exporter.go:115"
DEBU[0003] collect query: []                             source="rpi_exporter.go:37"
DEBU[0003] textfile collector succeeded after 0.000676s  source="collector.go:145"
DEBU[0003] cpu collector succeeded after 0.013211s       source="collector.go:145"
DEBU[0003] gpu collector succeeded after 0.130572s       source="collector.go:145"

I can see the temperature in Prometheus.

Please merge the PR...

Thanks a lot :-)

lukasmalkmus commented 5 years ago

v.0.6.0 is the new release.

ruzickap commented 5 years ago

Thank you :-)