# Lower cpufreq from watching sensors?

## TravisBy

My computer's been running a little... hot lately, and I'm afraid that while running at 3GHZ it'll hit 80C and shut down.  Is there any way I can have lm-sensors notice that it's at 65-70C, and lower tell cpufrequtils to lower to 2GHZ or something similar to that?  

Forgive me if this was the wrong place to post this, however I figured it'd go under kernel since the questions are involved with two kernel modules.

[edit]figured this'd be useful

 *uname -a wrote:*   

> Linux 192.168.1.3-gentoo 2.6.24-gentoo-r3 #1 SMP Wed Apr 2 10:05:07 EDT 2008 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ AuthenticAMD GNU/Linux
> 
> 

 

----------

## bunder

don't most newer cpus have overheating protection that does just that? (i mean before the mobo shuts off the machine)

i know my prescott (p4-3.0e) and my pentium-m laptop do...   :Confused: 

 *Quote:*   

> (from dmesg)
> 
> CPU1: Temperature above threshold
> 
> CPU0: Temperature above threshold
> ...

 

etc.

cheers

----------

## TravisBy

It overheated before, while running on 3GHZ.  I'm sure that was from the fans though [it was a prolonged time on 3GHZ, which I don't normally do].  I cleaned them out a few days ago, and I can certainly tell WHY it was overheating.

But, as it did, I guess it doesn't have anything for overheating protection :/

----------

## poly_poly-man

ummm... fix your heatsink? A 6000+ shouldn't get that hot...

Assuming it's formatted like k8temp (like it should be  :Very Happy:  ): 

```
#!/bin/sh

while true

do

   temp=`sensors k8temp-pci-00c3 | sed -e '/+[0-9][0-9]* C/ !d' -e 'q' | sed -e 's/+//' -e 's/ C//' -e 's/^[ \t]*//'`

   echo $temp

   if [ $temp -gt '65' ]

   then

      cpufreq-set -g powersave #or -f 2.00Ghz, etc.

   fi

   sleep 10 #in seconds... this will daemonize.

done
```

It's pretty simple, make sure to fix the k8temp... part for your CPU. Run sensors by itself to find the value it should be.

poly-p man

----------

## TravisBy

Thanks for the script poly, I have it set to run on boot.  I owe you ^.^

And ironically, that k8temp was exactly the same as mine.  

Also, forgive me, however what do you mean to "fix" my heatsink?  It's connected correctly, or should be.

----------

## poly_poly-man

 *TravisBy wrote:*   

> Thanks for the script poly, I have it set to run on boot.  I owe you ^.^
> 
> And ironically, that k8temp was exactly the same as mine.  
> 
> Also, forgive me, however what do you mean to "fix" my heatsink?  It's connected correctly, or should be.

 

Are you using the stock heatsink? Is the fan set up correctly? Is the thermal grease still good? Is the airflow in the case adequate?

My prescott used to get up to about 65 C, but I've never seen temperatures anywhere near that one my new system (a 4200+, but still...)

poly-p man

----------

## TravisBy

 *poly_poly-man wrote:*   

>  *TravisBy wrote:*   Thanks for the script poly, I have it set to run on boot.  I owe you ^.^
> 
> And ironically, that k8temp was exactly the same as mine.  
> 
> Also, forgive me, however what do you mean to "fix" my heatsink?  It's connected correctly, or should be. 
> ...

 

Yea, it's the stock.  When I bought it, the newegg reviews DID say it ran a  little hot.  Fan was attached to it when it came, so I'm assuming it's connected correctly, and I'd have no idea on how to check the thermal grease, however I haven't removed the heatsink/fan from the processor since slapping it on, so I'm going to assume that it's okay.  My case is built pretty well, I'm sure it has great air flow.

----------

## poly_poly-man

oh shit - that thing has a TDP of 125w - that about the same as prescott!!! Don't worry, your case is fine.

I assumed it was one of the nice ones, like my 65w or the nicer 45w - boy was I wrong  :Very Happy: 

Anyway, if you want my script to throttle the processor back up after a certain temperature, I'm sure you can figure out the proper if statement....

poly-p man

----------

## TravisBy

I usually run it on 1GHZ unless I"m doing something specific [emerging].  I don't do much to save electricity in this house, so that's about the only way I really can [What?  TURN a Gentoo machine off?  Why would ANYONE ever do that? =P]

And yea, it has a pretty strong requirement to use it, but it's worth it =P

Thanks for the help, was afraid I was going to need to buy something extra :/

----------

## poly_poly-man

If you generally keep it down, unless you are doing an emerge or something cpu-intensive, try out the "ondemand" governor.

My system stays at 1.0Ghz most of the time, but it will go to any of the other 3 frequencies when there is load on the processor, depending on how much there is.

And I don't even notice (unless I'm viewing youtube while compiling....   :Shocked:  )

poly-p man

----------

## TravisBy

 *poly_poly-man wrote:*   

> If you generally keep it down, unless you are doing an emerge or something cpu-intensive, try out the "ondemand" governor.
> 
> My system stays at 1.0Ghz most of the time, but it will go to any of the other 3 frequencies when there is load on the processor, depending on how much there is.
> 
> And I don't even notice (unless I'm viewing youtube while compiling....   )
> ...

 

That's what I use, however I have to switch between that and userspace because for some reason, X likes to take a lot of CPU [always the same %, but likes jumping all the way to 3GHZ] when I switch over to Warcraft [which I always have idling].  Frequency monitors are a BIG help with this  :Smile: 

----------

