diff options
author | Greg Frost <gregfrost1@bigpond.com> | 2009-08-15 05:31:58 (GMT) |
---|---|---|
committer | Greg Frost <gregfrost1@bigpond.com> | 2009-08-15 05:31:58 (GMT) |
commit | ac3fcc84dfa0692cf2b11a04d7266da47c2ff89c (patch) | |
tree | f86d811d39857cab00585406f6dcade718f06d72 /abs/core-testing/linhes-scripts/pause-mythcommflag.sh | |
parent | 119437a1508554051d060f88530263f3eb2204fb (diff) | |
download | linhes_pkgbuild-ac3fcc84dfa0692cf2b11a04d7266da47c2ff89c.zip linhes_pkgbuild-ac3fcc84dfa0692cf2b11a04d7266da47c2ff89c.tar.gz linhes_pkgbuild-ac3fcc84dfa0692cf2b11a04d7266da47c2ff89c.tar.bz2 |
linhes-scripts: repackage so src package contains files
Diffstat (limited to 'abs/core-testing/linhes-scripts/pause-mythcommflag.sh')
-rwxr-xr-x | abs/core-testing/linhes-scripts/pause-mythcommflag.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/abs/core-testing/linhes-scripts/pause-mythcommflag.sh b/abs/core-testing/linhes-scripts/pause-mythcommflag.sh new file mode 100755 index 0000000..4da808b --- /dev/null +++ b/abs/core-testing/linhes-scripts/pause-mythcommflag.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# pause-mythcommflag.sh v0.2 05/21/09 +# Utility to automatically pause & unpause mythcommflag if CPU usage is above a certain level +# Free for any use. +# Installation: +# cp pause-mythcommflag.sh /usr/LH/bin +# chmod +x /usr/LH/bin/pause-mythcommflag.sh +# Usage: Executed from sv start pause-mythcommflag + +# Threshold for when mythcommflag will be paused +CPUTHRESHOLD=75 + +# Second Threshold for when mythcommflag is already paused +PAUSEDCPUTHRESHOLD=45 + +# Log file to write (change to /dev/null for no log) +LOG=/var/log/mythtv/pause-mythcommflag.log + +# Number of seconds to wait between checking for mythcommflag process +SLEEP=5 + +#sleep $SLEEP + +touch $LOG + +COMMFLAGSTATE=1 + +while true; do + PROCCOMMFLAG=`pidof mythcommflag` + if [ -n "${PROCCOMMFLAG}" ] + then + FRONTENDCPU=`top -bn1u mythtv | grep mythfrontend | awk '{ print $9 }'` + if [ $COMMFLAGSTATE -eq 1 ] + then + CPUTHRESHOLD1=$CPUTHRESHOLD + else + CPUTHRESHOLD1=$PAUSEDCPUTHRESHOLD + fi + if [ "$FRONTENDCPU" -ge "$CPUTHRESHOLD1" ] + then +# echo "$(date) FE CPU $FRONTENDCPU% is greater than $CPUTHRESHOLD1%, PAUSE Commflagging" >> $LOG + kill -s STOP $PROCCOMMFLAG + COMMFLAGSTATE=0 + else +# echo "$(date) FE CPU $FRONTENDCPU% is less than $CPUTHRESHOLD1%, CONTINUE Commflagging" >> $LOG + kill -s CONT $PROCCOMMFLAG + COMMFLAGSTATE=1 + fi +# else +# echo "No COMMFLAG Process Active" >> $LOG + fi + sleep $SLEEP +done |