Collecting CPU temperature of the host running Indigo server

Posted on
Sat Apr 19, 2014 9:10 am
AndersKn offline
Posts: 8
Joined: Jan 12, 2014

Collecting CPU temperature of the host running Indigo server

Hi,

I thought I could share how I gather information about the host that is running the Indigo server, since I could not find any previous examples in the Indigo forums.
Disclaimer: I am not a software engineer, so my code WILL LOOK UGLY. If You don´t like it please feel free to improve! :-)

My situation is that the computer is located in a closet where the temperature may exceed the operating limit of the MacBookPro currently running the software.
Thus I thought it would be wise to monitor the CPU temperature.

To gather the sensor values from a unix prompt the choice fell upon a small utility called "Temperature Monitor" found at http://www.bresink.com/osx/TemperatureMonitor.html.
(This was the only software I found that can be used from command-line.)

From this I created a small AppleScript to collect the data and get it into Indigo. ( I have enclosed it in this post).

I´m interested to learn if others have had similar problems and if so how You solved it.


Best regards
Anders K.


Code: Select all
property return_f : false

try
   set the_result to (do shell script "/Applications/TemperatureMonitor.app/Contents/MacOS/tempmonitor -tv")
on error
   return "unknown"
end try


set alla_display to ""

# set thesensor to items 1 thru ((count of characters of the_result) - 5) of the_result
set thetemp1 to items 29 thru 30 of the_result
set thetemp2 to items 32 thru 33 of the_result

set thetemp1U to thetemp1 as Unicode text
set thetemp2U to thetemp2 as Unicode text

tell application "IndigoServer"
   -- This checks to see if a variable named "MyVar" exists, and creates it if it doesn't
   if not (variable "CPUtemp1" exists) then
      make new variable with properties {name:"CPUtemp1", value:"Value"}
   end if
   -- This line sets it
   set (value of variable "CPUtemp1") to thetemp1U
   if not (variable "CPUtemp2" exists) then
      make new variable with properties {name:"CPUtemp2", value:"Value"}
   end if
   -- This line sets it
   set (value of variable "CPUtemp2") to thetemp2U
end tell

Posted on
Sat Apr 19, 2014 9:47 am
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

Re: Collecting CPU temperature of the host running Indigo se

I implemented your solution. Works great.

Posted on
Sat Apr 19, 2014 10:47 am
BassMint offline
Posts: 105
Joined: Dec 24, 2013

Re: Collecting CPU temperature of the host running Indigo se

I recently set up hwmonitor to keep track of all the macs on the network.
I too am a novice as you, so the same things apply. The gurus are in vied to critique.

I tried it with AppleScript but found it to be better using Python grabbing from multiple hosts.

Code: Select all
#!/usr/bin/python
#  stinky hwmonitor
import subprocess

# get data from hwmonitor
stinkyRawValues =subprocess.Popen('ssh bassmint@stinky.local & /sbin/hwmonitor -f -tv', shell=True, stdout=subprocess.PIPE, )
stinkyValues= stinkyRawValues.communicate()[0]


# split into list
stinkyValues = stinkyValues.split(",")

 
indigo.variable.updateValue(209304751,stinkyValues[0]) # DATE_AND_TIME
indigo.variable.updateValue(461413176,stinkyValues[1]) # CPU_Core_1
indigo.variable.updateValue(1111349866,stinkyValues[2]) # CPU_Core_2
indigo.variable.updateValue(1606312189,stinkyValues[3]) # CPU_A_DIODE
indigo.variable.updateValue(760454415,stinkyValues[4]) # GPU_1_CHIP
indigo.variable.updateValue(415445737,stinkyValues[5]) # GPU_1_HEAT_SINK
indigo.variable.updateValue(203993904,stinkyValues[6]) # MAIN_HEAT_SINK_1
indigo.variable.updateValue(986309664,stinkyValues[7]) # MAIN_HEAT_SINK_2
indigo.variable.updateValue(1179140198,stinkyValues[8]) # MEMORY_CONTROLLER
indigo.variable.updateValue(749927948,stinkyValues[9]) # MEMORY_SENSOR_1
indigo.variable.updateValue(996721786,stinkyValues[10]) # CPU_A1
indigo.variable.updateValue(705416417,stinkyValues[11]) # GPU_SUPPLY_1A
indigo.variable.updateValue(360272147,stinkyValues[12]) # POWER_SUPPLY_BATTERY_1
indigo.variable.updateValue(1887879561,stinkyValues[13]) # CPU_A2
indigo.variable.updateValue(631155128,stinkyValues[14]) # GPU_SUPPLY_1B
indigo.variable.updateValue(1007332997,stinkyValues[15]) # POWER_SUPPLY_BATTERY_2
indigo.variable.updateValue(156029000,stinkyValues[17]) # CPU_A3
indigo.variable.updateValue(1782911323,stinkyValues[18]) # GPU_SUPPLY_1C
indigo.variable.updateValue(886599771,stinkyValues[19]) # POWER_SUPPLY_BATTERY_3
#indigo.variable.updateValue(1568895371,stinkyValues[20]) # FAN_Left_side
#indigo.variable.updateValue(1403505489,stinkyValues[21]) # FAN_Right_side
#indigo.variable.updateValue(582037091,stinkyValues[22]) # AMBIENT_LIGHT_1
#indigo.variable.updateValue(1917550312,stinkyValues[23]) # AMBIENT_LIGHT_2
#indigo.variable.updateValue(1375742121,stinkyValues[24]) # GPU
#indigo.variable.updateValue(134427035,stinkyValues[25]) # CPU_Clock_Frequency

indigo.server.log("HWM Got Stinky Data")


Not knowing exactly what Im doing, the above taps out after the first 20. Thats why they are commented out. I haven't dug any deeper into it recently as it got put on the back burner to figure out later.

Posted on
Wed Dec 28, 2016 7:17 pm
mclass offline
Posts: 184
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Collecting CPU temperature of the host running Indigo se

Like previous posters to this thread, I have located my Mac Mini running Inigo 7 on OSX 10.10.5 (Yosemite) in a comms locker.

During yesterday's heat (I'm in the southern hemisphere!) the temperature in the locker exceeded 30 degC, so I intend to install a fan that will operate when the temperature exceeds a certain level. Rather than install a separate temperature sensor, I thought it would be a good idea for Indigo to monitor CPU temperature and operate the fan as required.

However, the command line utility used in these examples is no longer available, and I have identified a Ruby gem - iStats [url](http://chris911.github.io/iStats)[/url].

As I have no experience with Ruby, I followed the provided install instructions with the following result:

Code: Select all
Indigo-Sandpit:~ sandpitserver$ sudo gem install iStats
Password:
Fetching: sparkr-0.4.1.gem (100%)
Successfully installed sparkr-0.4.1
Fetching: parseconfig-1.0.8.gem (100%)
Successfully installed parseconfig-1.0.8
Fetching: iStats-1.4.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing iStats:
   ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/iStats-1.4.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/iStats-1.4.0/ext/osx_stats/gem_make.out


As instructed in the installation instructions "for older versions of OSX" I tried:
Code: Select all
Indigo-Sandpit:~ sandpitserver$ sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install iStats
Building native extensions.  This could take a while...
ERROR:  Error installing iStats:
   ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Are there any Ruby "practitioners" out there that can assist?

Alternatively, are there better ideas for controlling cupboard ventilation (other than an additional temperature sensor)?

mclass

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron