forked from yanjost/munin-rpi-internal-temp
-
Notifications
You must be signed in to change notification settings - Fork 4
/
rpi-w1-temp
executable file
·42 lines (37 loc) · 1.15 KB
/
rpi-w1-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
#!/bin/bash
# Based on a script by a man named Andrew
# Originally located at http://blog.theinternets.be/rpi-munin-temperatures/
# Don't forget to load kernel modules: w1-gpio w1-therm
if [ "$1" == "autoconf" ]; then
if [ -e /sys/devices/w1_bus_master1/w1_master_slaves ]; then
echo "yes"
else
echo "no"
exit 1
fi
elif [ "$1" == "config" ]; then
echo "graph_title Raspberry Pi OneWire Temperature"
echo "graph_vlabel Temperature in Celsius"
echo "graph_category Sensors"
I=1;
for w1_slave in $(cat /sys/devices/w1_bus_master1/w1_master_slaves | sort)
do
echo "temp$I.warning 30"
echo "temp$I.critical 40"
echo "temp$I.label $w1_slave"
I=$((I+1));
done
else
I=1;
for w1_slave in $(cat /sys/devices/w1_bus_master1/w1_master_slaves | sort)
do
if test -f /sys/bus/w1/devices/$w1_slave/temperature; then
temp=$(</sys/bus/w1/devices/$w1_slave/temperature)
else
file=$(</sys/bus/w1/devices/$w1_slave/w1_slave)
temp=$(echo $file | sed -e 's/^.*=//' )
fi
awk "BEGIN { printf \"temp$I.value %2.3f\n\", $temp/1000 }"
I=$(($I+1));
done
fi