View Single Post
Gusse's Avatar
Posts: 168 | Thanked: 206 times | Joined on Apr 2010 @ Finland
#3022
I got lots of error when I tried to run Script for analyzing time_in_state (by rooted) - rev6 from wiki.maemo.org/Overclocking

Below is a bit modified version that run at least on my x-term. I don't understand why original file didn't run.

Code:
#!/bin/sh
currfreq=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`
idlefreq=`awk '{if ($2 > 0) print $1}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state | tail -n 1`
tis1=`awk '{sum += $2} END {print sum}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state`
tis2=`awk '$1 == 250000 {idle = $2} {sum += $2} END {print sum-idle}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state`
echo -e "
SCRIPT FOR ANALYZING TIME_IN_STATE
By rooted (maemo.org)
Revision 6 + some modifications

The script is in active development.
Update your script to current revision from:
wiki.maemo.org/Overclocking


FREQUENCY\tUSED\t\tWHEN BUSY"
result=`awk '{if ($1 >= 1000000) printf ("%.0f MHz\t",$1/1000); else printf (" %.0f MHz\t", $1/1000)}{if ($2 == 0) printf "unused\t"; else printf ("%.1f %\t\t",($2*100)/"'"$tis1"'")}{if ($2 == 0 || $2/"'"$tis2"'" > 1) printf "\n"; else printf ("%.1f %\n",($2*100)/"'"$tis2"'")}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state`
echo -e "
$result

Current frequency:   $currfreq\t\t\t MHz
Idle frequency:      $idlefreq\t\t\t MHz
Kernel:              `uname -r`
kernel-maemo:        `dpkg -l kernel* | awk '/kernel-maemo/ {print $3}'`
Uptime:              `uptime | sed -e 's/.*p *//' -e 's/, l.*//' -e 's/  / /'`
Load:                `uptime | sed 's/.*e: //'`
Boot reason:         `cat /proc/bootreason`
Temperature:         `cat /sys/class/power_supply/bq27200-0/temp` C\n"
---------------------------------------------------------------------------------------------
EDIT: When copying script from Overclocking wikipages, use ANSI coding when saving if you are using Windows, etc...
Notepad (also wordpad) adds hidden characters to each line which Unix doesn't like.

If you still get errors, then:
- open file in leafpad (or vi)
- copy all (ctrl-A)
- open a new leafpad
- paste (ctrl-V) copied content to new document
- save document
- chmod +x new document
- run it

Big Thanks to Rooted for help!

Last edited by Gusse; 2010-04-19 at 07:37. Reason: New guidance added