zhengzheng / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

CPUs temperature (Linux only) #371

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Proposal
I borrowed this idea from glances:
https://github.com/nicolargo/glances
...which internally uses pysensors:
https://pypi.python.org/pypi/PySensors/

On what platforms would this be available?
Linux 

Proposed API
Still not sure as I haven't looked into pysensors yet. Something like:

>>> psutil.cpu_temperature()
[cputemp(name='cpu1', temp=35), cputemp(name='cpu2', temp=30), ...]

psutil.cpu_temperature(celsius=False) could be used to express temperature in 
fahrenheit.
The order in which CPUs are returned should be the same as other cpu_* 
functions and be consistent across calls so that:

>>> psutil.cpu_temperature()[0]

...and:

>>> psutil.cpu_times(percpu=True)[0]

...will refer to the same CPU.

Original issue reported on code.google.com by g.rodola on 24 Apr 2013 at 12:59

GoogleCodeExporter commented 8 years ago
Committed in revision 22a650567ba7 in a separate branch by parsing files in 
/sys/class/hwmon/hwmon*/temp1_*. 
It is probably incomplete compared to what we can get via lm-sensors though so 
care should be taken on whether adding this or not.

Original comment by g.rodola on 27 Apr 2013 at 4:36

GoogleCodeExporter commented 8 years ago
OSX:
https://jira.hyperic.com/browse/SIGAR-12

Original comment by g.rodola on 17 Jun 2013 at 10:53

GoogleCodeExporter commented 8 years ago
Neither of these works on my macbook running 10.8.4:

[root@macbook ]# sysctl kern.cpu_temp_is_valid
second level name cpu_temp_is_valid in kern.cpu_temp_is_valid is invalid

[root@macbook ]$ sysctl kern.cpu_temp         
second level name cpu_temp in kern.cpu_temp is invalid

I also don't see any reference to temp sensors in sysctlbyname docs: 
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/
man3/sysctlbyname.3.html

Original comment by jlo...@gmail.com on 17 Jun 2013 at 6:49