forked from xe5700/kvmd-armbian
-
Notifications
You must be signed in to change notification settings - Fork 29
/
pi-temp
47 lines (38 loc) · 1.73 KB
/
pi-temp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Script: pi-temp.sh
# This should work on both arch and ubuntu/debian
# Purpose: Display the ARM CPU and GPU temperatures of Raspberry Pi 2/3/4/Zero
# Edited by: srepac <[email protected]>
# convert C to F and show both temps in output
# -------------------------------------------------------
# install basic calculator for conversions
if [ `which bc | wc -l` -le 0 ]; then
sudo apt-get install bc -y
fi
MODEL=$(tr -d '\0' </proc/device-tree/model)
# code section to get Pi RAM size
RAMGB=$( sudo vcgencmd get_config total_mem | awk -F= '{NUM = $2} END {
if ( NUM < 1024 ) print NUM "MB";
else print (NUM / 1024) "GB"; }' )
AVAIL=$( free -m | grep Mem | awk '{print $NF}' )
printf "$MODEL ${RAMGB} Hostname: $(hostname)\n$(date) Load average:$(uptime | awk -F: '{print $NF}') Avail RAM: ${AVAIL}MB\n"
GPUTEMP=`sudo $(which vcgencmd) measure_temp | awk -F= '{print $2}' | sed "s/'C//g"`
CPU=$(</sys/class/thermal/thermal_zone0/temp)
cpuC=`echo "scale=3; $CPU / 1000" | bc`
cpuF=`echo "scale=2; 9/5 * ${cpuC} + 32" | bc`
gpuF=`echo "scale=2; 9/5 * ${GPUTEMP} + 32" | bc`
#echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
printf "CPU => ${cpuC}'C\t${cpuF}'F\n"
printf "GPU => ${GPUTEMP}'C\t${gpuF}'F\n"
MHZ=`sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq`
#echo "CPU0 MHZ: $((MHZ/1000))"
#echo "CPU (All) MHz: "
count=0
for i in `sudo cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq`; do
cpu=`echo "scale=2; $i / 1000" | bc`
echo "CPU${count} MHz: $cpu"
count=`expr $count + 1`
done
sudo vcgencmd measure_volts | sed 's/volt=/vCore /g'
sudo vcgencmd get_throttled