command line tool to show CPU TEMP &. FAN SPEED

Posted on
Wed Jul 04, 2018 3:01 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

command line tool to show CPU TEMP &. FAN SPEED

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

Posted on
Fri Jul 06, 2018 9:13 am
george99 offline
Posts: 224
Joined: May 27, 2015

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

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.

Posted on
Fri Jul 06, 2018 10:43 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

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

Should be in downloads

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


Sent from my iPhone using Tapatalk

Posted on
Sat Jul 07, 2018 2:45 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

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

https://www.dropbox.com/s/tpqya1b242d4e9e/osx-cpu-temp.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

Posted on
Sat Jul 07, 2018 8:34 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

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

and here a more complete version:
https://www.dropbox.com/s/82aeddlijy9msvh/osx-temp-fan.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 2545 times

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests