Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //ini_set('display_errors', 1);
- // CPU temperature lazy mode
- $temp = shell_exec('sudo vcgencmd measure_temp');
- $temp = substr($temp, 5, -3);
- // ARM frequency lazy mode
- $freq = shell_exec('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq');
- $freq = intval($freq) / 1000;
- // Throttle
- $codes=array(
- 0=>"Under-voltage detected",
- 1=>"Arm frequency capped",
- 2=>"Currently throttled",
- 3=>"Soft temperature limit active",
- 16=>"Under-voltage has occurred",
- 17=>"Arm frequency capped has occurred",
- 18=>"Throttling has occurred",
- 19=>"Soft temperature limit has occurred");
- $thro = '';
- $output=shell_exec("sudo vcgencmd get_throttled");
- $output=explode("x",$output);
- $output=array_map('trim', $output);
- if ($output[1] == "0") {
- $thro = "No";
- } else {
- $output=str_split($output[1]);
- $bincode="";
- foreach ($output as $hex) {
- $bincode.=str_pad(base_convert($hex,16,2),4,"0",STR_PAD_LEFT);
- }
- $bincode=array_reverse(str_split($bincode));
- foreach ($bincode as $k=>$v) {
- if ($v) {
- $thro = $codes[$k];
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement