-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_rpi_temp.sh
45 lines (39 loc) · 1.08 KB
/
check_rpi_temp.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
#!/bin/bash
export PATH=$PATH:"/opt/vc/bin"
#FOR NRPE, ADD:"/bin/chmod u+s /opt/vc/bin/vcgencmd" TO /etc/rc.local (last line must be exit 0)
SHUT_HIGH_TEMP=70
SHUT_MIN_TEMP=5
CRIT_HIGH_TEMP=67
CRIT_MIN_TEMP=10
WARNING_HIGH_TEMP=58
WARNING_MIN_TEMP=10
CPU_TEMP=`/opt/vc/bin/vcgencmd measure_temp`
CPU_TEMP=${CPU_TEMP:5:-4}
if which vcgencmd >/dev/null; then
COMMANDFOUND=1
else
echo "CRITICAL - Command vcgencmd not found in $PATH"
exit 2
fi
if [ "$CPU_TEMP" -gt "$WARNING_MIN_TEMP" ] && [ "$CPU_TEMP" -lt "$WARNING_HIGH_TEMP" ];
then
echo "OK - Core is $CPU_TEMP Celsius"
exit 0
fi
if [ "$CPU_TEMP" -lt "$SHUT_MIN_TEMP" ] || [ "$CPU_TEMP" -ge "$SHUT_HIGH_TEMP" ];
then
echo "CRITICAL - SHUTTING DOWN - Core is $CPU_TEMP Celsius"
logger "CRITICAL - SHUTTING DOWN - Core is $CPU_TEMP Celsius"
/sbin/shutdown -hP -t 2
exit 2
fi
if [ "$CPU_TEMP" -le "$CRIT_MIN_TEMP" ] || [ "$CPU_TEMP" -ge "$CRIT_HIGH_TEMP" ];
then
echo "CRITICAL - Core is $CPU_TEMP Celsius"
exit 2
else
echo "WARNING - Core is $CPU_TEMP Celsius"
exit 1
fi
echo "UNKNOWN - Script Internal problem"
exit 3