- enable the use of the red button on my streamzap remote to restart X
- calculate the last time a button was pressed on the remote and if
more that 90 minutes has elapsed will simulate an ESCAPE and stop live
tv to reduce the chance of my frontend crashing
- monitors mythfrontend CPU usage and CPU temp and restarts X if > 90% / 90 C
just put scripts in root tftp directory and minimyth.script will download them
John
minimyth.script:
Code: Select all
mkdir /var/spool
mkdir /var/spool/cron
mkdir /var/spool/cron/crontabs
tftp 192.168.27.10 -g -r minimyth.cron -l /var/spool/cron/crontabs/minimyth
crond
tftp 192.168.27.10 -g -r ct -l /home/minimyth/ct
chmod +x /home/minimyth/ct
tftp 192.168.27.10 -g -r mythpowerbutton.sh -l /home/minimyth/mythpowerbutton.sh
chmod +x /home/minimyth/mythpowerbutton.sh
tftp 192.168.27.10 -g -r checklastbuttonpress -l
/home/minimyth/checklastbuttonpress
chmod +x /home/minimyth/checklastbuttonpress
tftp 192.168.27.10 -g -r buttonpress -l /home/minimyth/buttonpress
chmod +x /home/minimyth/buttonpress
-----------------------------------------------------------------------------------------------------------------------------
relevant part of lircrc:
Code: Select all
begin
prog = irexec
button = POWER
repeat = 10
config = /home/minimyth/mythpowerbutton.sh
end
begin
prog = irexec
button = *
repeat = 10
config = /home/minimyth/buttonpress
end
ct (monitors cpu usage/ mythfrontend)
Code: Select all
#!/bin/sh
MFC=`top -n 1 | grep mythfrontend | awk {' if ( $6 > 90 ) print 1'}`
#change 90 to whatever
MFT=`sensors | grep "CPU Temp" | awk {' if ( $3 > 90 ) print 1'}` #
change 90 to whatever
if [ "$MFT" -eq "1" ]
then
echo 'MYTHFRONTEND restart due to temp more than 90' >>/home/minimyth/messages
/home/minimyth/mythpowerbutton.sh #
elif [ "$MFC" -eq "1" ]
then
echo 'MYTHFRONTEND restart due to cpu % more than 90' >>/home/minimyth/messages
/home/minimyth/mythpowerbutton.sh
else
echo `date` CPU Temp `sensors | grep "CPU Temp" | awk {' print $3 '}`C, Mythfrontend CPU `top -n 1 | grep mythfrontend | awk {' print $6 '}`'%' >>/home/minimyth/messages
fi
mythpowerbutton.sh (restarts X)
Code: Select all
#!/bin/sh
killall mythfrontend
wait
echo `date` "SYSTEM RESTARTED" >> /home/minimyth/messages
/etc/rc.d/init.d/x start
buttonpress (logs when any remote control button is pressed):
Code: Select all
#!/bin/sh
echo `date +%s` > /home/minimyth/lastpress
checklastbuttonpress (run by cron to calculate when last button pressed)
Code: Select all
#!/bin/sh
LP=`cat /home/minimyth/lastpress`
NW=`date +%s`
DIFF=`echo $LP $NW | awk {'print $2-$1'}`
echo `date` 'check last button push:' $DIFF ' seconds'>>/home/minimyth/messages
if [ $DIFF -gt 5400 ] #can change 5400 to however many seconds required
then
echo "key escape" | nc 192.168.27.11 6546
echo `date` 'Escape key simulated'>>/home/minimyth/messages
fi
minimyth.cron:
Code: Select all
11 * * * * /home/minimyth/ct
*/10 * * * * /home/minimyth/checklastbuttonpress