Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] please add cpu temperature meter #36

Closed
aszurnasirpal opened this issue Nov 14, 2021 · 10 comments · Fixed by #232
Closed

[Request] please add cpu temperature meter #36

aszurnasirpal opened this issue Nov 14, 2021 · 10 comments · Fixed by #232
Labels
enhancement New feature or request

Comments

@aszurnasirpal
Copy link

I think that one of the most important sensor that should be visualized in th system diagnostic tab should be CPU temp.

@aszurnasirpal aszurnasirpal changed the title add cpu temperature meter [Request] please add cpu temperature meter Nov 14, 2021
@MichaIng MichaIng added the enhancement New feature or request label Nov 14, 2021
@MichaIng
Copy link
Collaborator

MichaIng commented Nov 14, 2021

Good idea. I wonder how to implement best, I guess loading DietPi-Globals to run the G_OBTAIN_CPU_TEMP function in a shell is pretty overkill, though to give a precise temperature, different /sys tunables need to be read on every hardware. Probably there is a slim library available as Rust crate to do this with higher efficiency and same precision without invoking an external process.

Last but not least the logic could be cloned: https://github.com/MichaIng/DietPi/blob/733d81e/dietpi/func/dietpi-globals#L1692-L1722
But this means doubled code maintenance if something changes 🤔.

@ravenclaw900
Copy link
Owner

The crate that I'm currently using to read CPU, RAM, etc has a function for that: https://docs.rs/heim/0.1.0-rc.1/heim/sensors/fn.temperatures.html.

@MichaIng
Copy link
Collaborator

That is great. Hopefully it is accurate on the various SBCs we support.

@ravenclaw900
Copy link
Owner

I've been trying to work on this, but I've run into some problems (heim-rs/heim#354). Until that gets resolved, my basic changes are in the https://github.com/ravenclaw900/DietPi-Dashboard/tree/cpu-temp branch.

@ravenclaw900 ravenclaw900 mentioned this issue Jan 27, 2022
24 tasks
@BeekeeperNL
Copy link

isn't it something like this?....

root@DietPi:/# watch -n 2 sensors

Every 2.0s: sensors DietPi: Thu Feb 10 17:17:03 2022

amdgpu-pci-0008
Adapter: PCI adapter
vddgfx: 1.55 V
vddnb: 787.00 mV
edge: +18.0°C

k10temp-pci-00c3
Adapter: PCI adapter
temp1: +18.8°C (high = +70.0°C)
(crit = +100.0°C, hyst = +99.0°C)

fam15h_power-pci-00c4
Adapter: PCI adapter
power1: 9.05 mW (avg = 1.19 mW, interval = 0.01 s)
(crit = 6.00 W)

@ravenclaw900
Copy link
Owner

While that might work (though it doesn't on my RPi, does the sensors command need to be installed?), we try to use native Rust code instead of shell scripts, to keep the binary self-contained.

@MichaIng
Copy link
Collaborator

apt install lm-sensors and the (C) library is libsensors5.

@BeekeeperNL
Copy link

BeekeeperNL commented Feb 10, 2022

ah okay, i understand. sorry i was having trouble seeing why it was difficult to have the cpu temp seeing as it is posted each time i login via ssh. I understand now why this is not what you are trying to do, least not in this way. and yes, i used lm-sensors and no.. it's not a pi. but it should work just as well on a pi.

@MichaIng
Copy link
Collaborator

Via bash shell and sourcing /boot/dietpi/func/dietpi-globals, there is G_OBTAIN_CPU_TEMP available which does the job without additional dependencies/libraries. But loading a shell + this quite large script is probably too much overhead:

bash -c '. /boot/dietpi/func/dietpi-globals; G_OBTAIN_CPU_TEMP'

Otherwise the logic, looping though the kernel API until a valid integer was found, could be directly implemented: https://github.com/MichaIng/DietPi/blob/4eee867/dietpi/func/dietpi-globals#L1674-L1716

@MichaIng MichaIng linked a pull request Aug 19, 2022 that will close this issue
@MichaIng
Copy link
Collaborator

MichaIng commented Aug 19, 2022

Implemented already for next release v0.6.1 with: #232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants