Ticket #36 (new enhancement)

Opened 4 years ago

Last modified 2 years ago

OS X temperature information

Reported by: chris Owned by:
Priority: major Milestone:
Component: OSX Version:
Keywords: Cc:

Description

The following shell script fetches temperature information on OS X using "ioreg". Use it as a reference for adding the same capability to Eddie.

if [ `uname` == "Darwin" ]
 then

# help message

 if [ "$1" == "-h" ]
  then 
  basename=`echo $0 | sed 's/.*\///'`
  echo "usage: $basename [option]"
  echo "     -l also show Machine Name and CPU Type"
  echo "     -h display this help message"
  echo "     -e <regex> diplay only lines that match regex"
  exit
 fi

# if -l display Machine Name and CPU Type

 if [ "$1" == "-l" ]
  then
  system_profiler SPHardwareDataType | awk '/Machine Name/ || /Machine Model/ || /CPU Type/' | sed 's/[^:]*: //' | awk '{ printf $0 "  " }'
  echo
 fi
 
# sensor data
sensors=`ioreg -n IOHWSensor | awk '/location/ || /current-value/ || /"type"/' | sed -e 's/[^"]*"//' -e 's/" =//' -e 's/location//' -e 's/type//' -e 's/"//g' | awk '{ d=($2/65536); if ($1=="current-value") print substr(d,1,7) "\t" ; if ($1!="current-value") print $0 }' | sed -e 's/temperature/Celsius/' -e 's/voltage/volts/' -e 's/fanspeed/fan RPM/' -e 's/current/Amps/' -e 's/^temp$//' -e 's/ //' | awk '{ if ((NR % 3) == 0) print $0; else printf $0 " " }'`

# 

if [ "$1" == "-e" ]
 then
 if [ "$2" == "" ]
  then
  echo no regex selected
 else
  echo "$sensors" | awk "/$2/"
 fi
else
 echo "$sensors"
fi

# error message if unsupported machine 
 
else
 echo -e "\nThis appears not to be an OS X machine\n"
fi

Change History

Changed 2 years ago by chris

  • milestone eddie-0.36 deleted
Note: See TracTickets for help on using tickets.