Mercurial > repos > other > usr-local-bin
annotate sensors-record @ 38:737061eac1d0 default tip
Skip more large videos and some permission issues
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 18 Aug 2021 20:40:17 +0100 |
parents | fe0a21557acd |
children |
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 |
34 | 39 # We can't guarantee order, so sort the results |
40 # People also report that the ACPI sensor is unreliable, so only take temps with "low" properties, which ACPI seems to lack | |
41 SENSORS=$(sensors | grep '^\(fan\|temp.*low\|Core\)' | sort | sed 's/Core /Core/g; s/^\([^:]\+\): [^0-9\.]*\([0-9\.]\+\)[^ ]*/\1 \2/g' | awk '{printf "%s:", $2}') | |
12
3adc69ceb249
Add sensor recording and graph generating scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 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
|
43 # "N" means record against current timestamp |
3adc69ceb249
Add sensor recording and graph generating scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 rrdtool update "${DB}" "N:${SENSORS}${GPU%:}" |
3adc69ceb249
Add sensor recording and graph generating scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 sleep 1 |
3adc69ceb249
Add sensor recording and graph generating scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 done |
3adc69ceb249
Add sensor recording and graph generating scripts
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 |