Mercurial > repos > other > usr-local-bin
comparison sensors-record @ 12:3adc69ceb249
Add sensor recording and graph generating scripts
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 08 Jul 2017 18:28:27 +0100 |
parents | |
children | fb4dd1974129 |
comparison
equal
deleted
inserted
replaced
11:d45ad0c070de | 12:3adc69ceb249 |
---|---|
1 #! /bin/bash | |
2 # Record system temps and fan speeds in an RRD database | |
3 # Built using http://web-tech.ga-usa.com/2011/08/simple-rrdtool-linux-system-temperatures/index.html as a reference | |
4 | |
5 type rrdtool >/dev/null 2>&1 || { echo "Could not find rrdtool" >&2; exit 1; } | |
6 type sensors >/dev/null 2>&1 || { echo "Could not find sensors" >&2; exit 1; } | |
7 | |
8 DB=$HOME/.temps.rrd | |
9 | |
10 if [[ ! -e "${DB}" ]] | |
11 then | |
12 #Note: "Virt" device also exists, but ALWAYS reports | |
13 # the same temperatures | |
14 rrdtool create "${DB}" --step 1 \ | |
15 DS:core1-temp:GAUGE:2:0.0:100.0 \ | |
16 DS:core2-temp:GAUGE:2:0.0:100.0 \ | |
17 DS:core3-temp:GAUGE:2:0.0:100.0 \ | |
18 DS:core4-temp:GAUGE:2:0.0:100.0 \ | |
19 DS:fan1:GAUGE:2:0:5000 \ | |
20 DS:fan2:GAUGE:2:0:5000 \ | |
21 DS:fan3:GAUGE:2:0:5000 \ | |
22 DS:fan4:GAUGE:2:0:5000 \ | |
23 DS:fan5:GAUGE:2:0:5000 \ | |
24 DS:isa-temp1:GAUGE:2:0.0:100.0 \ | |
25 DS:isa-temp2:GAUGE:2:0.0:100.0 \ | |
26 DS:isa-temp3:GAUGE:2:0.0:100.0 \ | |
27 DS:gpu:GAUGE:2:0.0:100.0 \ | |
28 DS:gpu-fan:GAUGE:2:0:100.0 \ | |
29 RRA:AVERAGE:0.5:1:3600 \ | |
30 RRA:AVERAGE:0.5:60:360 \ | |
31 RRA:AVERAGE:0.5:300:8640 # 1hr of 1sec, 6hrs of 1min and 1mo of 5m resolution | |
32 # Temps above 100 are bad! | |
33 # Fans assume max 5000RPM | |
34 # nVidia fan reports in percent | |
35 fi | |
36 | |
37 while true | |
38 do | |
39 SENSORS=$(sensors | grep '^\(fan\|temp\|Core\)' | tail -n+3 | sed 's/Core /Core/g; s/^\([^:]\+\): [^0-9\.]*\([0-9\.]\+\)[^ ]*/\1 \2/g' | awk '{printf "%s:", $2}') | |
40 GPU=$(nvidia-smi -q | grep -oE "(Fan Speed|GPU Current Temp).*"|sort -r|cut -f2 -d:|cut -f2 -d" "|tr '\n' ':') | |
41 # "N" means record against current timestamp | |
42 rrdtool update "${DB}" "N:${SENSORS}${GPU%:}" | |
43 sleep 1 | |
44 done | |
45 |