forked from greearb/lanforge-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheatmon.bash
More file actions
executable file
·40 lines (39 loc) · 966 Bytes
/
heatmon.bash
File metadata and controls
executable file
·40 lines (39 loc) · 966 Bytes
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
#!/bin/bash
#
# Use this script to report sensors output to journalctl. This script
# should be invoked from a systemd-timer. Use lf_kinstall.pl --do_heatmon to create
# the systemd timer unit. The timer should probably only run once a minute.
#
if [[ ! -x /usr/bin/jq ]]; then
echo "Unable to find jq."
exit 1
fi
if [[ ! -x /usr/bin/sensors ]]; then
echo "Unable to find sensors"
exit 1
fi
# JQ_FORMULA='[.| to_entries |.[] | {A: .key, T: .value.temp1.temp1_input}]'
JQ_FORMULA=$( cat <<- 'EOF'
[ to_entries[]
| .key as $chip
| .value
| to_entries[]
| select(.value | type == "object")
| .key as $core
| .value
| to_entries[]
| select(.key | test("temp.*input"))
| {
# ($chip +"."+ $core):(.value),
A: ($chip +"."+ $core+"."+.key),
T: .value
}
]
EOF
)
if [[ -n "${1:-}" ]] && [[ -r "$1" ]]; then
grep -v ERROR < "$1" | jq -c "$JQ_FORMULA"
fi
/usr/bin/sensors -u -j 2>/dev/null \
| jq -c "$JQ_FORMULA"
#