-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_throttled.sh
executable file
·69 lines (63 loc) · 1.5 KB
/
get_throttled.sh
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
ISSUES_MAP=( \
[0]="Under-voltage detected" \
[1]="Arm frequency capped" \
[2]="Currently throttled"
[3]="Soft temperature limit active" \
[16]="Under-voltage has occurred" \
[17]="Arm frequency capping has occurred" \
[18]="Throttling has occurred" \
[19]="Soft temperature limit has occurred")
HEX_BIN_MAP=( \
["0"]="0000" \
["1"]="0001" \
["2"]="0010" \
["3"]="0011" \
["4"]="0100" \
["5"]="0101" \
["6"]="0110" \
["7"]="0111" \
["8"]="1000" \
["9"]="1001" \
["A"]="1010" \
["B"]="1011" \
["C"]="1100" \
["D"]="1101" \
["E"]="1110" \
["F"]="1111" \
)
THROTTLED_OUTPUT=$(vcgencmd get_throttled)
IFS='x'
read -a strarr <<< "$THROTTLED_OUTPUT"
THROTTLED_CODE_HEX=${strarr[1]}
# Display current issues
echo "Current issues:"
CURRENT_HEX=${THROTTLED_CODE_HEX:4:1}
CURRENT_BIN=${HEX_BIN_MAP[$CURRENT_HEX]}
if [ "$CURRENT_HEX" == "0" ] || [ -z $CURRENT_HEX ]; then
echo "No throttling issues detected."
else
bit_n=0
for (( i=${#CURRENT_BIN}-1; i>=0; i--)); do
if [ "${CURRENT_BIN:$i:1}" = "1" ]; then
echo "~ ${ISSUES_MAP[$bit_n]}"
bit_n=$((bit_n+1))
fi
done
fi
echo ""
# Display past issues
echo "Previously detected issues:"
PAST_HEX=${THROTTLED_CODE_HEX:0:1}
PAST_BIN=${HEX_BIN_MAP[$PAST_HEX]}
if [ $PAST_HEX = "0" ]; then
echo "No throttling issues detected."
else
bit_n=16
for (( i=${#PAST_BIN}-1; i>=0; i--)); do
if [ "${PAST_BIN:$i:1}" = "1" ]; then
echo "~ ${ISSUES_MAP[$bit_n]}"
bit_n=$((bit_n+1))
fi
done
fi