Advertisement
Guest User

pistats-fa.sh

a guest
Jun 11th, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.92 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Set the path to your webroot here
  4. WEBROOT='/usr/share/dump1090-fa/html'
  5.  
  6. # Get current CPU frequency
  7. STAT1=$(sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
  8.  
  9. # vcgencmd commands
  10. # Return current cpu temperature
  11. STAT2=$(sudo vcgencmd measure_temp)
  12. STAT2=${STAT2:5:-2}
  13.  
  14. # Return current voltage
  15. STAT3=$(sudo vcgencmd measure_volts)
  16. STAT3=${STAT3:5:-1}
  17.  
  18. # Return throttle state
  19. STAT4=$(sudo vcgencmd get_throttled)
  20. STAT4=${STAT4:10}
  21.  
  22. # Which Pi model do we have?
  23. STAT5=$(sudo cat /sys/firmware/devicetree/base/model | tr '\0' '\n')
  24.  
  25. JSON_STRING=$( sudo jq -n \
  26.                 --arg fr "$STAT1" \
  27.                 --arg te "$STAT2" \
  28.                 --arg vo "$STAT3" \
  29.                 --arg th "$STAT4" \
  30.                 --arg mo "$STAT5" \
  31.                 '{freq: $fr, temp: $te, volt: $vo, throttle: $th, model: $mo}')
  32.  
  33. echo $JSON_STRING > pistats.json
  34. sudo mv pistats.json $WEBROOT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement