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