simple cpufreq scaling bash script

Hi

I had a problem with frequency scaling with my fileserver
dmesg shows me:

ondemand governor failed, too long transition latency of HW, fallback to performance governor

so i’d coded my own scaling script )

#!/bin/bash

loadavg=$(cat /proc/loadavg | awk '{print $1}')
thisloadavg=$(echo $loadavg | awk -F . '{print $1}')
cpufreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed)
maxfreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq)
minfreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq)
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)

if [ "$governor" != "userspace" ]; then
	echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
fi

if [ "$cpufreq" -eq "$minfreq" ]; then
	if [ "$thisloadavg" -ge "2" ]; then
		echo $maxfreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
	fi
fi

if [ "$cpufreq" -eq "$maxfreq" ]; then
	if [ "$thisloadavg" -le "1" ]; then
		echo $minfreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
	fi
fi

SImply add it to crontab

Have Fun!