Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Temperature-related power off
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC
View previous topic :: View next topic  
Author Message
youth against youth
n00b
n00b


Joined: 17 Jul 2006
Posts: 14
Location: Rimini

PostPosted: Wed Jul 26, 2006 11:25 pm    Post subject: Temperature-related power off Reply with quote

Hi there, since i've noticed that is usual for my powerbook (12'' 1Ghz) to poweroff during heavy compilation I've writed a tiny stupid bash script to avoid that by stopping the process and wiating until the cpu temp is back to a safe value. Maybe someone wil find it useful (or maybe someone could improve it) so i've decided to post it here. :)

Code:
#!/bin/bash
 
# this script is born to save my laptop from poweroff due to high temperature
# It takes 3 argument:
# TARGET: the process which you want to be eventually stoppe (Or supposed to beresponsible of the cpu high usage)
# MAX: temperature which is considered dangerous for the system
# SAFE: temperature under which is considered safe to restart the process
# if no SAFE or MAX are provided on commandline we have dafaults defined.
# The CPUTEMP_PATH could be very system specific (I think) so double check before running

TARGET=$1
SAFE=$3
MAX=$2
CPUTEMP_PATH=/sys/devices/temperatures/sensor1_temperature
CPUTEMP=$(cat  $CPUTEMP_PATH)
SAFE_DEFAULT=50
MAX_DEFAULT=66
if [ -z $TARGET ]; then
echo "ERROR: I need a process name as argument"
echo "USAGE: tempchk.sh process_name (safe_temp max_temp)"
echo "If max_temp or safe_temp are not provided we will take max=$MAX_DEFAULT and safe=$SAFE_DEFAULT as default"
exit;
else
#check the temp parameters and if null revert to default
if [ -z $SAFE ]; then SAFE=$SAFE_DEFAULT;fi;
if [ -z $MAX ]; then MAX=$MAX_DEFAULT;fi;
if [ "$MAX" -le "$SAFE" ]; then
        echo "ERROR: The safe temperature is highet than the max temperature"
        exit;
fi;
while true;
#I know, I know I will burn in hell for this "while true"
        do
                if [ "$CPUTEMP" -ge "$MAX" ] ; #do we need to stop?
                then
                        `skill -STOP $TARGET`
                        echo "Process $TARGET stopped due to cpu temperature limit excedeed"
                fi;
                if  [ $CPUTEMP -le $SAFE ] ; #is safe to resume?
                then
                        `skill -CONT $TARGET`
                        echo "Cpu temperature is sitting in the defined interval"
echo "Bringing back to life $TARGET if is stopped.."
                fi;
        sleep 30;
        #maybe the cpu temp is changed in the meanwhile
        CPUTEMP=$(cat $CPUTEMP_PATH);
done;
fi;


I'm not very good at scripting and my english is poor so I apologize in advance :oops:
_________________
--
Cristiano Balducci
Think for yourself and question authority
Back to top
View user's profile Send private message
JoseJX
Retired Dev
Retired Dev


Joined: 28 Apr 2002
Posts: 2774

PostPosted: Thu Jul 27, 2006 4:48 am    Post subject: Reply with quote

Please make sure that the module therm_adt746x is either loaded or built into your kernel (better), otherwise, you'll observe overheating like this.
_________________
Gentoo PPC FAQ: http://www.gentoo.org/doc/en/gentoo-ppc-faq.xml
Back to top
View user's profile Send private message
youth against youth
n00b
n00b


Joined: 17 Jul 2006
Posts: 14
Location: Rimini

PostPosted: Thu Jul 27, 2006 8:15 am    Post subject: Reply with quote

Code:
Oni ~ # cat /usr/src/linux/.config|grep THERM
# CONFIG_THERM_WINDTUNNEL is not set
CONFIG_THERM_ADT746X=y


Even with ADT746 when you've got to compile Ooffice its hard to "survive" :)
_________________
--
Cristiano Balducci
Think for yourself and question authority
Back to top
View user's profile Send private message
bz31
Tux's lil' helper
Tux's lil' helper


Joined: 20 Apr 2005
Posts: 108

PostPosted: Thu Jul 27, 2006 12:52 pm    Post subject: Reply with quote

How to use limit_adjust option if therm_adt746x is built into the kernel ?
Back to top
View user's profile Send private message
JoseJX
Retired Dev
Retired Dev


Joined: 28 Apr 2002
Posts: 2774

PostPosted: Thu Jul 27, 2006 1:18 pm    Post subject: Reply with quote

youth against youth:
Okay, just checking. :)

bz31:
You can adjust these values in /sys/module/therm_adt746x/parameters. I suggest building it in because you don't want to forget to load the module, or accidentally unload it. :p
_________________
Gentoo PPC FAQ: http://www.gentoo.org/doc/en/gentoo-ppc-faq.xml
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum