mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-04-19 12:57:16 +00:00
raspberrypi (all): replace brownout script with proper throttle watcher
This commit is contained in:
parent
b1ec5ad898
commit
2f3b2774f9
@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
check_interval=30
|
||||
readv=/sys/class/leds/led1/brightness
|
||||
|
||||
test -e "$readv" || exit 0
|
||||
|
||||
test -n "$os_version" || source /etc/init.d/base
|
||||
|
||||
watch() {
|
||||
while true; do
|
||||
if [ "$(cat $readv)" == "0" ]; then
|
||||
logger -t brownout -s "low power supply voltage detected"
|
||||
fi
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
msg_begin "Starting brownout detector"
|
||||
watch &
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
stop)
|
||||
msg_begin "Stopping brownout detector"
|
||||
ps | grep brownout | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
64
board/raspberrypi/overlay/etc/init.d/S11throttlewatch
Executable file
64
board/raspberrypi/overlay/etc/init.d/S11throttlewatch
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
check_interval=30
|
||||
|
||||
test -n "$os_version" || source /etc/init.d/base
|
||||
|
||||
get_throttled_now() {
|
||||
t=$(vcgencmd get_throttled | cut -d '=' -f 2)
|
||||
test $((t & 1)) -ne 0 && echo -n "under-voltage "
|
||||
test $((t & 2)) -ne 0 && echo -n "arm-frequency-capped "
|
||||
test $((t & 4)) -ne 0 && echo -n "throttled "
|
||||
}
|
||||
|
||||
get_throttled_since_boot() {
|
||||
t=$(vcgencmd get_throttled | cut -d '=' -f 2)
|
||||
test $((t & 65536)) -ne 0 && echo -n "under-voltage "
|
||||
test $((t & 131072)) -ne 0 && echo -n "arm-frequency-capped "
|
||||
test $((t & 262144)) -ne 0 && echo -n "throttled "
|
||||
}
|
||||
|
||||
watch_now() {
|
||||
while true; do
|
||||
t=$(get_throttled_now)
|
||||
if [ -n "$t" ]; then
|
||||
logger -t throttlewatch -s "currently: $t"
|
||||
fi
|
||||
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
watch_since_boot() {
|
||||
while true; do
|
||||
t=$(get_throttled_since_boot)
|
||||
if [ -n "$t" ]; then
|
||||
logger -t throttlewatch -s "since boot: $t"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
msg_begin "Starting throttle watcher"
|
||||
watch_now &
|
||||
watch_since_boot &
|
||||
10 test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
stop)
|
||||
msg_begin "Stopping throttle watcher"
|
||||
ps | grep throttlewatch | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
check_interval=30
|
||||
readv=/sys/class/leds/led1/brightness
|
||||
|
||||
test -e "$readv" || exit 0
|
||||
|
||||
test -n "$os_version" || source /etc/init.d/base
|
||||
|
||||
watch() {
|
||||
while true; do
|
||||
if [ "$(cat $readv)" == "0" ]; then
|
||||
logger -t brownout -s "low power supply voltage detected"
|
||||
fi
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
msg_begin "Starting brownout detector"
|
||||
watch &
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
stop)
|
||||
msg_begin "Stopping brownout detector"
|
||||
ps | grep brownout | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
64
board/raspberrypi2/overlay/etc/init.d/S11throttlewatch
Executable file
64
board/raspberrypi2/overlay/etc/init.d/S11throttlewatch
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
check_interval=30
|
||||
|
||||
test -n "$os_version" || source /etc/init.d/base
|
||||
|
||||
get_throttled_now() {
|
||||
t=$(vcgencmd get_throttled | cut -d '=' -f 2)
|
||||
test $((t & 1)) -ne 0 && echo -n "under-voltage "
|
||||
test $((t & 2)) -ne 0 && echo -n "arm-frequency-capped "
|
||||
test $((t & 4)) -ne 0 && echo -n "throttled "
|
||||
}
|
||||
|
||||
get_throttled_since_boot() {
|
||||
t=$(vcgencmd get_throttled | cut -d '=' -f 2)
|
||||
test $((t & 65536)) -ne 0 && echo -n "under-voltage "
|
||||
test $((t & 131072)) -ne 0 && echo -n "arm-frequency-capped "
|
||||
test $((t & 262144)) -ne 0 && echo -n "throttled "
|
||||
}
|
||||
|
||||
watch_now() {
|
||||
while true; do
|
||||
t=$(get_throttled_now)
|
||||
if [ -n "$t" ]; then
|
||||
logger -t throttlewatch -s "currently: $t"
|
||||
fi
|
||||
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
watch_since_boot() {
|
||||
while true; do
|
||||
t=$(get_throttled_since_boot)
|
||||
if [ -n "$t" ]; then
|
||||
logger -t throttlewatch -s "since boot: $t"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
msg_begin "Starting throttle watcher"
|
||||
watch_now &
|
||||
watch_since_boot &
|
||||
10 test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
stop)
|
||||
msg_begin "Stopping throttle watcher"
|
||||
ps | grep throttlewatch | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
check_interval=30
|
||||
readv=/sys/class/leds/led1/brightness
|
||||
|
||||
test -e "$readv" || exit 0
|
||||
|
||||
test -n "$os_version" || source /etc/init.d/base
|
||||
|
||||
watch() {
|
||||
while true; do
|
||||
if [ "$(cat $readv)" == "0" ]; then
|
||||
logger -t brownout -s "low power supply voltage detected"
|
||||
fi
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
msg_begin "Starting brownout detector"
|
||||
watch &
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
stop)
|
||||
msg_begin "Stopping brownout detector"
|
||||
ps | grep brownout | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
64
board/raspberrypi3/overlay/etc/init.d/S11throttlewatch
Executable file
64
board/raspberrypi3/overlay/etc/init.d/S11throttlewatch
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
check_interval=30
|
||||
|
||||
test -n "$os_version" || source /etc/init.d/base
|
||||
|
||||
get_throttled_now() {
|
||||
t=$(vcgencmd get_throttled | cut -d '=' -f 2)
|
||||
test $((t & 1)) -ne 0 && echo -n "under-voltage "
|
||||
test $((t & 2)) -ne 0 && echo -n "arm-frequency-capped "
|
||||
test $((t & 4)) -ne 0 && echo -n "throttled "
|
||||
}
|
||||
|
||||
get_throttled_since_boot() {
|
||||
t=$(vcgencmd get_throttled | cut -d '=' -f 2)
|
||||
test $((t & 65536)) -ne 0 && echo -n "under-voltage "
|
||||
test $((t & 131072)) -ne 0 && echo -n "arm-frequency-capped "
|
||||
test $((t & 262144)) -ne 0 && echo -n "throttled "
|
||||
}
|
||||
|
||||
watch_now() {
|
||||
while true; do
|
||||
t=$(get_throttled_now)
|
||||
if [ -n "$t" ]; then
|
||||
logger -t throttlewatch -s "currently: $t"
|
||||
fi
|
||||
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
watch_since_boot() {
|
||||
while true; do
|
||||
t=$(get_throttled_since_boot)
|
||||
if [ -n "$t" ]; then
|
||||
logger -t throttlewatch -s "since boot: $t"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep $check_interval
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
msg_begin "Starting throttle watcher"
|
||||
watch_now &
|
||||
watch_since_boot &
|
||||
10 test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
stop)
|
||||
msg_begin "Stopping throttle watcher"
|
||||
ps | grep throttlewatch | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
Loading…
x
Reference in New Issue
Block a user