[mythtv] Potentially Useful Scripts

David A. Mason damason at redshift.com
Wed Dec 17 17:00:24 EST 2003


I have made two scripts to check for misbehavior (mythbehavior?), and they
run periodically in cron:

Myth lock present but service not running:
================
#!/bin/sh

if test -f /var/lock/subsys/mythbackend ; then
        echo "Myth subsys set"
        running=`eval ps aux | grep mythback | grep -v grep | wc -l | awk '{
print $1 }'`
        if [ $running -eq "0" ] ; then
                echo "*** Error: mythbackend found stopped at `date` ***"
>>/var/log/mythbackend.log
                rmmod -r ivtv msp3400 saa7115
                modprobe ivtv
                /etc/rc.d/init.d/mythbackend restart
                echo "*** mythbackend restarted at `date` ***"
>>/var/log/mythbackend.log
        fi
fi
================



and Myth/ivtv producing zero-length files:
================
#!/bin/sh

if test -f /var/lock/subsys/mythbackend ; then
        echo "Myth subsys set"
        NOW=`date '+%b %e %R'`
        ZEROS = `eval ls -l /var/video/record/*nuv | grep " 0 $NOW" | wc -l
| awk '{ print $1 }'`
        if [ $ZEROS -ne "0" ] ; then
                echo "*** Error: mythbackend making zero-length files at
`date` ***" >>/var/log/mythbackend.log
                rmmod -r ivtv msp3400 saa7115
                modprobe ivtv
                /etc/rc.d/init.d/mythbackend restart
                echo "*** mythbackend restarted at `date` ***"
>>/var/log/mythbackend.log
        fi
fi
================

The latter hasn't really been tested much, but I'm about to schedule it. It
might be necessary to tell it to reboot rather than just reloading the
driver and mythbackend, however.

One further caveat is that I have modified the mythbackend rc script to
delete its lockfile on stop and restart:
================
stop() {
        echo -n "Stopping ${MBE_PROG}: "
        killproc ${MBE_LOCATION}${MBE_PROG}
        rm -f /var/lock/subsys/${MBE_PROG}
        echo
        return $RETVAL
}
================




More information about the mythtv-dev mailing list