Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- $arr=Array();
- $max=intval(file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'))/100;
- $ct=intval(shell_exec("ls /sys/devices/system/cpu/ | grep 'cpu[0-9]' | wc -l"));
- for($i=0;$i<60;$i=$i+1){
- for($x=0;$x<$ct;$x=$x+1){
- $val=intval(file_get_contents("/sys/devices/system/cpu/cpu$x/cpufreq/cpuinfo_cur_freq"));
- if(!in_array($val,$arr)){
- echo "Found: " . str_pad($val/1000,4," ",STR_PAD_LEFT) . " Mhz as " . str_pad(round($val/$max),3," ",STR_PAD_LEFT) . "%\n";
- array_push($arr,$val);
- }
- }
- shell_exec('sleep 1');
- }
- sort($arr,SORT_NUMERIC);
- $ct=count($arr);
- echo implode(',',$arr). "\nTotal found: " . $ct . "\nSorted data:\n";
- for($i=0;$i<$ct;$i=$i+1){
- echo str_pad($arr[$i]/1000,4," ",STR_PAD_LEFT) . " Mhz as " . str_pad(round($arr[$i]/$max),3," ",STR_PAD_LEFT) . "%\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement