Advertisement
Guest User

pistats.php

a guest
Jun 10th, 2020
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <?php
  2. //ini_set('display_errors', 1);
  3.  
  4. // CPU temperature lazy mode
  5. $temp = shell_exec('sudo vcgencmd measure_temp');
  6. $temp = substr($temp, 5, -3);
  7.  
  8. // ARM frequency lazy mode
  9. $freq = shell_exec('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq');
  10. $freq = intval($freq) / 1000;
  11.  
  12. // Throttle
  13. $codes=array(
  14. 0=>"Under-voltage detected",
  15. 1=>"Arm frequency capped",
  16. 2=>"Currently throttled",
  17. 3=>"Soft temperature limit active",
  18. 16=>"Under-voltage has occurred",
  19. 17=>"Arm frequency capped has occurred",
  20. 18=>"Throttling has occurred",
  21. 19=>"Soft temperature limit has occurred");
  22.  
  23. $thro = '';
  24. $output=shell_exec("sudo vcgencmd get_throttled");
  25. $output=explode("x",$output);
  26. $output=array_map('trim', $output);
  27.  
  28. if ($output[1] == "0") {
  29.         $thro = "No";
  30. } else {
  31.         $output=str_split($output[1]);
  32.         $bincode="";
  33.         foreach ($output as $hex) {
  34.                 $bincode.=str_pad(base_convert($hex,16,2),4,"0",STR_PAD_LEFT);
  35.         }
  36.         $bincode=array_reverse(str_split($bincode));
  37.         foreach ($bincode as $k=>$v) {
  38.                 if ($v) {
  39.                         $thro = $codes[$k];
  40.                 }
  41.         }
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement