Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Bring back the CPU + Temp real time meter
#2
Hi Rafa,

I don't disagree that when making system modifications and tweaks that things like CPU freq, ram, disk, temp etc can be helpful indicators but just not as regular parts of the UI. When CPU and temp were on audio info screen they were still just snapshots same as on System info.

If you want to try a quick and dirty util then just paste the code below into a file named /home/pi/systat.php. Use Ctrl-c to quit the util. It updates every two seconds as a result of taking two 1 second snapshots of cpu utilization via top.

-Tim

Code:
#!/usr/bin/php
<?php

while(true) {
    $cpuload = exec("top -bn 2 -d 1.0 | grep 'Cpu(s)' | tail -n 1 | awk '{print $2 + $4 + $6}'");
    $cpuload = number_format($cpuload,0,'.','');
    $cputemp = substr(shell_exec('cat /sys/class/thermal/thermal_zone0/temp'), 0, 2);
    $cpufreq = (float)shell_exec('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq');
    
    if ($cpufreq < 1000000) {
            $cpufreq = number_format($cpufreq / 1000, 0, '.', '');
            $cpufreq .= ' MHz';
    }
    else {
            $cpufreq = number_format($cpufreq / 1000000, 1, '.', '');
            $cpufreq .= ' GHz';
    }
    
    $result = trim(exec('grep -c ^processor /proc/cpuinfo'));
    $cores = $result > 1 ? $result . ' cores' : $result . ' core';
    $sysarch = trim(shell_exec('uname -m'));
    
    echo $cpufreq . ' | ' . $cpuload . '%' . ' | ' . $cputemp . "\xB0" . ' | ' . $cores . ' | ' . $sysarch . "\r";
}
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
RE: Bring back the CPU + Temp real time meter - by Tim Curtis - 04-11-2018, 07:25 PM

Forum Jump: