diff options
author | Greg Frost <gregfrost1@bigpond.com> | 2009-08-04 01:22:18 (GMT) |
---|---|---|
committer | Greg Frost <gregfrost1@bigpond.com> | 2009-08-04 01:22:18 (GMT) |
commit | e85c92735d5ce5f790cf95a0ea02e08c264e170a (patch) | |
tree | 037a1921e8f6899fea9b5daaaf998ec746367298 /abs/core-testing/linhes-scripts/src/limit-mythcommflag.sh | |
parent | 82af083e07eb189ac930678224a5748551cf69f8 (diff) | |
parent | 120212bdd438d98c52aaab5b43443258be81a7e4 (diff) | |
download | linhes_pkgbuild-e85c92735d5ce5f790cf95a0ea02e08c264e170a.zip linhes_pkgbuild-e85c92735d5ce5f790cf95a0ea02e08c264e170a.tar.gz linhes_pkgbuild-e85c92735d5ce5f790cf95a0ea02e08c264e170a.tar.bz2 |
Merge branch 'master' of ssh://gregfrost@knoppmyth.net/mount/repository/LinHES-PKGBUILD
Diffstat (limited to 'abs/core-testing/linhes-scripts/src/limit-mythcommflag.sh')
-rwxr-xr-x | abs/core-testing/linhes-scripts/src/limit-mythcommflag.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/abs/core-testing/linhes-scripts/src/limit-mythcommflag.sh b/abs/core-testing/linhes-scripts/src/limit-mythcommflag.sh new file mode 100755 index 0000000..8ca61c7 --- /dev/null +++ b/abs/core-testing/linhes-scripts/src/limit-mythcommflag.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# limit-mythcommflag.sh v0.1 05/17/09 +# Utility to automatically limit mythcommflag if CPU usage is above a certain level. +# Uses cpulimit from http://cpulimit.sourceforge.net/ +# Free for any use. +# Installation: +# cp limit-mythcommflag.sh /usr/LH/bin +# chmod +x /usr/LH/bin/limit-mythcommflag.sh +# Usage: Executed from runit limit-mythcommflag at boot + +# Threshold for when mythcommflag will be paused +CPUTHRESHOLD=43 + +# Limit mythcommflag to percentage +LIMITCPU=20 + +# Log file to write (use /dev/null for no log) +#LOG=/var/log/mythtv/limit-mythcommflag.log +LOG=/dev/null + +# Number of seconds to wait between checking for mythcommflag process +SLEEP=5 + +#sleep $SLEEP + +touch $LOG + +ALREADYLIMITED=0 + +while true; do + PROCCOMMFLAG=`pidof mythcommflag` + if [ -n "${PROCCOMMFLAG}" ] + then + FRONTENDCPU=`top -bn1u mythtv | grep mythfrontend | awk '{ print $9 }'` + if [ "$FRONTENDCPU" -ge "$CPUTHRESHOLD" ] + then + echo "$(date) FE CPU $FRONTENDCPU% is greater than $CPUTHRESHOLD%, LIMIT Commflagging" # >> $LOG + if [ $ALREADYLIMITED -eq 0 ]; then + cpulimit -e mythcommflag -l $LIMITCPU & + cpulimit_pid=$! + ALREADYLIMITED=1 + fi + else + echo "$(date) FE CPU $FRONTENDCPU% is less than $CPUTHRESHOLD%, UNLIMIT Commflagging" #>> $LOG + if [ $ALREADYLIMITED -eq 1 ]; then + kill $cpulimit_pid + ALREADYLIMITED=0 + fi + fi +# else +# echo "No COMMFLAG Process Active" >> $LOG + fi + sleep $SLEEP +done |