Pi66

pino-rs
Rust notification daemon.
git clone https://git.pi66.xyz/pino-rs

scripts/cpu-monitor.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

MAX_TEMP=70
CHECK_INTERVAL=0.3
THERMAL_ZONE="/sys/class/thermal/thermal_zone3/temp"
COOLDOWN_TEMP=$((MAX_TEMP - 20))  # 50°C in this case

[ ! -f "$THERMAL_ZONE" ] && pino -t "Error" -m "Thermal zone not found!" -d 10 && exit 1

while true; do
    temp=<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mo stretchy="false">&#x00028;</mo><mo stretchy="false">&#x00028;</mo></mrow></math>(cat "$THERMAL_ZONE") / 1000))

    if [ "<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>t</mi><mi>e</mi><mi>m</mi><mi>p</mi><mi>"</mi><mo>&#x02212;</mo><mi>g</mi><mi>t</mi><mi>"</mi></mrow></math>MAX_TEMP" ]; then
        pino -t "CPU Overheating Warning" -m "Current temperature: ${temp}°C" -d 5
        while [ "<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>t</mi><mi>e</mi><mi>m</mi><mi>p</mi><mi>"</mi><mo>&#x02212;</mo><mi>g</mi><mi>t</mi><mi>"</mi></mrow></math>COOLDOWN_TEMP" ]; do
            sleep "$CHECK_INTERVAL"
            temp=<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mo stretchy="false">&#x00028;</mo><mo stretchy="false">&#x00028;</mo></mrow></math>(cat "$THERMAL_ZONE") / 1000))
        done
    fi

    sleep "$CHECK_INTERVAL"
done