command line tool to show CPU TEMP &. FAN SPEED

User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

command line tool to show CPU TEMP &. FAN SPEED

Post by kw123 »

Have created a little executable and posted the file on my dropbox, .... see new download for zip file

following/using: https://github.com/lavoiesl/osx-cpu-temp
george99
Posts: 226
Joined: Wed May 27, 2015 4:51 pm

Re: command line tool to show CPU TEMP &. FAN SPEED

Post by george99 »

Hi, I Ean your executable, and I created a var in indigo called "cpuTemp".
When I run the script (python) nothing happens.

When I downloaded your zip file, I downloaded it to my downloads folder and then unzipped it right there. I am not sure where the file that was created is located though.
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: command line tool to show CPU TEMP &. FAN SPEED

Post by kw123 »

Should be in downloads

You should move it to eg
~
Then the path should be
/users/yourid/


Sent from my iPhone using Tapatalk
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: command line tool to show CPU TEMP &. FAN SPEED

Post by kw123 »

https://www.dropbox.com/s/tpqya1b242d4e ... p.zip?dl=1

updated file: no more options, output:

Code: Select all

./osx-cpu-temp
temp:36.2--rpm:1300.0:1220.0
temp is C and rpm is list of fan speeds ":" separated

the zipfile:

Code: Select all

-rwxr-xr-x  1 karlwachs  staff  13876 Jul  7 10:34 osx-cpu-temp
-rw-r--r--  1 karlwachs  staff   3009 Jul  7 10:37 osx-cpu-temp.zip
to populate variable(s): add schedule - eg every 5 minutes- and in action/ server/script

Code: Select all

import subprocess 
data = (subprocess.Popen("pathToFile/osx-cpu-temp",shell=True,stdout=subprocess.PIPE).communicate()[0].strip("\n")).split("--rpm")
temp = data[0].split(":")[1] #  temp is is C, 
#to convert to F: temp = "%.1f"%(float(temp) *9/5. +32)
indigo.variable.updateValue("cpuTemp", temp) #  variable cpuTemp must already exist,

if len(data) > 1:
  fanSpeeds = data[1].strip(":") 
  indigo.variable.updateValue("fanSpeeds", fanSpeeds) #  variable fanSpeeds must already exist
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: command line tool to show CPU TEMP &. FAN SPEED

Post by kw123 »

and here a more complete version:
https://www.dropbox.com/s/82aeddlijy9ms ... n.zip?dl=1

Code: Select all

./osx-temp-fan
temp_AMBIENT_AIR_0:27.1
temp_AMBIENT_AIR_1:-99.0
temp_CPU_0_DIE:-99.0
temp_CPU_0_DIODE:46.9
temp_CPU_0_HEATSINK:-99.0
temp_CPU_0_PROXIMITY:43.6
temp_ENCLOSURE_BASE_0:-99.0
temp_ENCLOSURE_BASE_1:-99.0
temp_ENCLOSURE_BASE_2:-99.0
temp_ENCLOSURE_BASE_3:-99.0
temp_GPU_0_DIODE:-99.0
temp_GPU_0_HEATSINK:-99.0
temp_GPU_0_PROXIMITY:-99.0
temp_HDD_PROXIMITY:31.6
temp_HEATSINK_0:-99.0
temp_HEATSINK_1:-99.0
temp_HEATSINK_2:-99.0
temp_LCD_PROXIMITY:-99.0
temp_MEM_SLOT_0:64.0
temp_MEM_SLOTS_PROXIMITY:49.0
temp_MISC_PROXIMITY:-99.0
temp_NORTHBRIDGE:48.0
temp_NORTHBRIDGE_DIODE:63.5
temp_NORTHBRIDGE_PROXIMITY:-99.0
temp_ODD_PROXIMITY:-99.0
temp_PALM_REST:-99.0
temp_PWR_SUPPLY_PROXIMITY:-99.0
temp_THUNDERBOLT_0:-99.0
temp_THUNDERBOLT_1:-99.0
fan0Speed:856.5
fan1Speed:799.8
fan2Speed:956.5
fan3Speed:689.2
and the indigo code to import into variables:

Code: Select all

import subprocess 
### change the path to the path where the executable is located
data = (subprocess.Popen("/users/karlwachs/indigo//osx-temp-fan",shell=True,stdout=subprocess.PIPE).communicate()[0].strip("\n")).split("\n")

tUnit ="C"
t_format = "%.1f"
for line in data:
    ll = line.split(":")
    if len(ll) < 2: continue
    if  ll[0].find("temp") > -1:
        t = float(ll[1])
        if t < 0: continue
        if tUnit == "F": 
            t = t*9./5/+32
        try:      indigo.variables[ll[0]]
        except:   indigo.variable.create(ll[0])
        indigo.variable.updateValue(ll[0], t_format%t)
    else:
        try:      indigo.variables[ll[0]]
        except:   indigo.variable.create(ll[0])
        indigo.variable.updateValue(ll[0], ll[1]) 
It will automatically create the temp and fan variables. values of -99 mean: no info, no variable will be created.

This code assumes the executable is in ~/indigo/
It was tested under El Capitan and High Sierra

if the executable "osx-temp-fan" is not "executable", right click on file info and add "execute" to the rights.

Karl
Attachments
Screen Shot 2018-07-07 at 4.31.48 PM.png
Screen Shot 2018-07-07 at 4.31.48 PM.png (79.86 KiB) Viewed 3467 times
Post Reply

Return to “Karl's Plugins and Scripts”