Raspberry Pi (all): S11throttlewatch: log current temperature

This commit is contained in:
Calin Crisan 2020-04-13 18:05:45 +03:00
parent 923b931647
commit 8c57d5e76b
4 changed files with 40 additions and 28 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
CHECK_INTERVAL=30 CHECK_INTERVAL=60
test -n "${OS_VERSION}" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
@ -19,12 +19,16 @@ get_throttled_since_boot() {
test $((t & 262144)) -ne 0 && echo -n "throttled " test $((t & 262144)) -ne 0 && echo -n "throttled "
} }
get_temp() {
t=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((t / 1000))"
}
watch_now() { watch_now() {
while true; do while true; do
t=$(get_throttled_now) th=$(get_throttled_now)
if [[ -n "${t}" ]]; then te=$(get_temp)
logger -t throttlewatch -s "currently: ${t}" logger -t throttlewatch "currently: ${th:-ok}, temperature: ${te} C"
fi
sleep ${CHECK_INTERVAL} sleep ${CHECK_INTERVAL}
done done
@ -34,7 +38,7 @@ watch_since_boot() {
while true; do while true; do
t=$(get_throttled_since_boot) t=$(get_throttled_since_boot)
if [[ -n "${t}" ]]; then if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "since boot: ${t}" logger -t throttlewatch "since boot: ${t}"
break break
fi fi
@ -62,4 +66,3 @@ case "$1" in
esac esac
exit $? exit $?

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
CHECK_INTERVAL=30 CHECK_INTERVAL=60
test -n "${OS_VERSION}" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
@ -19,12 +19,16 @@ get_throttled_since_boot() {
test $((t & 262144)) -ne 0 && echo -n "throttled " test $((t & 262144)) -ne 0 && echo -n "throttled "
} }
get_temp() {
t=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((t / 1000))"
}
watch_now() { watch_now() {
while true; do while true; do
t=$(get_throttled_now) th=$(get_throttled_now)
if [[ -n "${t}" ]]; then te=$(get_temp)
logger -t throttlewatch -s "currently: ${t}" logger -t throttlewatch "currently: ${th:-ok}, temperature: ${te} C"
fi
sleep ${CHECK_INTERVAL} sleep ${CHECK_INTERVAL}
done done
@ -34,7 +38,7 @@ watch_since_boot() {
while true; do while true; do
t=$(get_throttled_since_boot) t=$(get_throttled_since_boot)
if [[ -n "${t}" ]]; then if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "since boot: ${t}" logger -t throttlewatch "since boot: ${t}"
break break
fi fi
@ -62,4 +66,3 @@ case "$1" in
esac esac
exit $? exit $?

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
CHECK_INTERVAL=30 CHECK_INTERVAL=60
test -n "${OS_VERSION}" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
@ -19,12 +19,16 @@ get_throttled_since_boot() {
test $((t & 262144)) -ne 0 && echo -n "throttled " test $((t & 262144)) -ne 0 && echo -n "throttled "
} }
get_temp() {
t=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((t / 1000))"
}
watch_now() { watch_now() {
while true; do while true; do
t=$(get_throttled_now) th=$(get_throttled_now)
if [[ -n "${t}" ]]; then te=$(get_temp)
logger -t throttlewatch -s "currently: ${t}" logger -t throttlewatch "currently: ${th:-ok}, temperature: ${te} C"
fi
sleep ${CHECK_INTERVAL} sleep ${CHECK_INTERVAL}
done done
@ -34,7 +38,7 @@ watch_since_boot() {
while true; do while true; do
t=$(get_throttled_since_boot) t=$(get_throttled_since_boot)
if [[ -n "${t}" ]]; then if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "since boot: ${t}" logger -t throttlewatch "since boot: ${t}"
break break
fi fi
@ -62,4 +66,3 @@ case "$1" in
esac esac
exit $? exit $?

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
CHECK_INTERVAL=30 CHECK_INTERVAL=60
test -n "${OS_VERSION}" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
@ -19,12 +19,16 @@ get_throttled_since_boot() {
test $((t & 262144)) -ne 0 && echo -n "throttled " test $((t & 262144)) -ne 0 && echo -n "throttled "
} }
get_temp() {
t=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((t / 1000))"
}
watch_now() { watch_now() {
while true; do while true; do
t=$(get_throttled_now) th=$(get_throttled_now)
if [[ -n "${t}" ]]; then te=$(get_temp)
logger -t throttlewatch -s "currently: ${t}" logger -t throttlewatch "currently: ${th:-ok}, temperature: ${te} C"
fi
sleep ${CHECK_INTERVAL} sleep ${CHECK_INTERVAL}
done done
@ -34,7 +38,7 @@ watch_since_boot() {
while true; do while true; do
t=$(get_throttled_since_boot) t=$(get_throttled_since_boot)
if [[ -n "${t}" ]]; then if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "since boot: ${t}" logger -t throttlewatch "since boot: ${t}"
break break
fi fi
@ -62,4 +66,3 @@ case "$1" in
esac esac
exit $? exit $?