View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 24 posts ] 
Go to page 1, 2  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Tue May 22, 2007 9:14 pm 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
check it out...let me know what you think! i let it run if LiveTV is recording because i don't really care if it stutters. its the scheduled recordings that i am concerned about...nothing worse than looking forward to watching something you've recorded and then seeing that Myth dropped frames due to filldatabase running! well, there are probobly worse things in life, but it is pretty damn annoying!

Code:
#!/bin/sh
# --------------------------------------------------------------------
# Very simple script to execute mythfilldatabase only if there are no
# scheduled recordings currently being recorded.

# Written by:   Neil Loknath
# Date:         May 22 2007
#---------------------------------------------------------------------

# initalize variables
script='MFDB:'
db='mythconverg'


# substitute the username you want to you use to connect to mySQL
user='root'

# password variable is here, but I haven't used it
password=''
mfdb='mythfilldatabase --quiet'

# run SQL
data=`mysql $db -u $user -e "select count(*) from recorded where timediff(now(),endtime)<'00:00:00' and recgroup!='LiveTV';" -sN`

if [ $data -ge 1 ]; then
        echo "$script MythTV is currently recording a scheduled program.  Please run mythfilldatabase at another time."
else
        echo "$script MythTV will now run $mfdb"
        $mfdb
fi

exit 0

_________________
os: knoppmyth r5e50
mobo: asus p5pe-vm
cpu: intel celeron 2.66 d
memory: 256mb ddr ram
video: asus geforce 6200 agp
tuner: hauppauge pvr 150 mce
disk: seagate 250gb sata


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 5:57 am 
Offline
Joined: Tue Sep 12, 2006 6:03 am
Posts: 210
Location: Roseville, MI
Nice script. I was looking to write something just like this for a mythbackup. cron job Now I have something to reference.

I just need to add something in there about checking for future recording that may happen in the next 0-30minutes. This will make sure that when the script is doing its thing there are no recording to be found.

_________________
-Roseville, Michigan USA
LinHES R8: FE/BE, FE (x2)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 8:49 am 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
that's a good idea. i'll have to add the check for future recordings, as well.

_________________
os: knoppmyth r5e50
mobo: asus p5pe-vm
cpu: intel celeron 2.66 d
memory: 256mb ddr ram
video: asus geforce 6200 agp
tuner: hauppauge pvr 150 mce
disk: seagate 250gb sata


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 8:50 am 
Offline
Joined: Sat Feb 11, 2006 5:26 pm
Posts: 282
Location: Winnipeg - Canada
Spidey, if/when you add the code to look for upcoming recordings would you mind posting it here? I'd like to add this to my system and your addition sounds like a good one.

_________________
Currently Running:
Too lazy to update this with my current hardware, I'll redo it during my next install =)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 10:52 am 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
Here is an update...hasn't been fully tested, but I think this should work:

Code:
#!/bin/sh
# --------------------------------------------------------------------
# Very simple script to execute mythfilldatabase only if there are no
# scheduled recordings currently being recorded.

# Written by:   Neil Loknath
# Date:         May 22 2007
#---------------------------------------------------------------------

# initalize variables
script='MFDB:'
db='mythconverg'


# substitute the username you want to you use to connect to mySQL
user='root'

# password variable is here, but I haven't used it
password=''
mfdb='mythfilldatabase --quiet'

# run SQL
data1=`mysql $db -u $user -e "select count(*) from recorded where timediff(now(),endtime)<'00:00:00' and recgroup!='LiveTV';" -sN`
data2=`mysql $db -u $user -e "select count(*) from record where inactive=0 and (type!=0 or type!=8) and timediff(now(),concat(startdate,' ',starttime))<'00:30:00';" -sN`

if [ $data1 -ge 1 -o $data2 -ge 1 ]; then
        echo "$script MythTV is/will be recording a scheduled program.  Please run mythfilldatabase at another time."
else
        echo "$script MythTV will now run $mfdb"
        $mfdb
fi

exit 0

_________________
os: knoppmyth r5e50
mobo: asus p5pe-vm
cpu: intel celeron 2.66 d
memory: 256mb ddr ram
video: asus geforce 6200 agp
tuner: hauppauge pvr 150 mce
disk: seagate 250gb sata


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 1:19 pm 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
I was happy to see this script. Although running mythfilldatabase while recording isn't an issue for me, forgetting to check whether there was activity on the box before I rebooted was. I modified the above script to suit my needs.
Code:
#!/bin/sh

# initalize variables
db='mythconverg'
data0=0
data1=0
data2=0

# substitute the username you want to you use to connect to mySQL
user='root'

# password variable is here, but I haven't used it
password=''

# run SQL
data0=`mysql $db -u $user -e "select count(*) from inuseprograms where recusage like 'player'" -sN`
data1=`mysql $db -u $user -e "select count(*) from inuseprograms where recusage like 'recorder'" -sN`
data2=`mysql $db -u $user -e "select count(*) from record where inactive=0 and (type!=0 or type!=8) and timediff(now(),concat(startdate,' '$

if [ $data0 -ge 1 -o $data1 -ge 1 -o $data2 -ge 1 ]; then
        echo -e "\033[31m         WARNING!!!"
        echo -e "\033[0mMythTV is watching $data0 program(s)"
        echo "MythTV is recording $data1 program(s)"
        echo "MythTV is scheduled $data2 program(s) within 10 minutes";
        echo -e "\nDo you still wish to reboot? (y/n)"
        read ANSW
        case $ANSW in
         y) reboot ;;
         *) exit 0
        esac
else
        echo "Rebooting"
        reboot
fi

exit 0
I've also created an alias for this to the reboot command to idiot-proof rebooting against myself

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 6:07 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Brilliant work guys. I'll be adding this to my wrapper scripts for mythfilldatabase. Something like this has been on my ToDo list for a couple months now. I may even turn it into a generic safety check to be used with various things...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 7:50 pm 
Offline
Joined: Fri Oct 20, 2006 12:04 pm
Posts: 905
Location: LA, CA
how about something along these lines applied to the "backup:, so you don't kill the BE just before your scheduled to record? would it be hard to adapt?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 8:19 pm 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
I've found an issue where recording in the next 10 minutes aren't being reported properly. It seems that when I rescheduled a show it then came up in as being recorded in the next 10 minutes. It has something to do with the time until the next recording being a negative number. I'll investigate more tomorrow.

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 8:35 pm 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
Found it:
Code:
#!/bin/sh

# initalize variables
db='mythconverg'
user='root'
password=''

data0=`mysql $db -u $user -e "select count(*) from inuseprograms where recusage like 'player'" -sN`
data1=`mysql $db -u $user -e "select count(*) from inuseprograms where recusage like 'recorder'" -sN`
data2=`mysql $db -u $user -e "select count(*) from record \
        where inactive=0 and (type!=0 or type!=8) and \
        timediff(sysdate(),concat(startdate,' ',starttime))<'00:10:00' and \
        timediff(concat(startdate,' ',starttime),sysdate())<'00:10:00';\
        " -sN`

if [ $data0 -ge 1 -o $data1 -ge 1 -o $data2 -ge 1 ]; then
        echo -e "\033[31m\n         WARNING!!!\033[0m\n"
        if [ $data0 -ge 1 ]; then
                echo "MythTV is watching $data0 program(s)"
        fi
        if [ $data1 -ge 1 ]; then
                echo "MythTV is recording $data1 program(s)"
        fi
        if [ $data2 -ge 1 ]; then
                echo "MythTV has scheduled $data2 program(s) within 10 minutes"
        fi
        echo -e "\nDo you still wish to reboot? (y/n)"
        read ANSW
        case $ANSW in
         y) reboot ;;
         *) exit 0
        esac
else
        echo "Rebooting"
        reboot
fi

exit 0

Edit: Prettied it up

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Last edited by Gnarl on Thu May 24, 2007 7:06 am, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 10:04 pm 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
gnarl, can you describe again exactly how to re-create the problem? i dont quite understand what happened?

_________________
os: knoppmyth r5e50
mobo: asus p5pe-vm
cpu: intel celeron 2.66 d
memory: 256mb ddr ram
video: asus geforce 6200 agp
tuner: hauppauge pvr 150 mce
disk: seagate 250gb sata


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 7:08 am 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
Try making a new schedule to record something right now. When I tried that, the new schedule show in the script as being recorded within the next 10 minutes.

When I troubleshot the script, the timediff() had a result of eg -03:21:00 hours which is less then 10 minutes.

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 8:55 am 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
ok thanks...i see the problem and, potentially, another one. it looks like the startdate in the record table is always the date of the first recording in a series of recordings (ex. weekly, daily, etc.) i'll post some new code when i get the chance.

_________________
os: knoppmyth r5e50
mobo: asus p5pe-vm
cpu: intel celeron 2.66 d
memory: 256mb ddr ram
video: asus geforce 6200 agp
tuner: hauppauge pvr 150 mce
disk: seagate 250gb sata


Last edited by imstr8trippin on Thu May 24, 2007 10:16 am, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 9:25 am 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
Too Many Secrets wrote:
how about something along these lines applied to the "backup:, so you don't kill the BE just before your scheduled to record? would it be hard to adapt?
I don't think this should be too hard to incorporate into the backup, but in the mean time you can make your own hack by replacing reboot with mythbackup in the script and creating an alias

BUT... this may create problems running mythbackup from the frontend interface. A 5 second timeout may be necessary.

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 10:09 am 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
Gnarl wrote:
BUT... this may create problems running mythbackup from the frontend interface. A 5 second timeout may be necessary.
Another way i found to solve this is to alias command for use on the command line and use the absolute path to the command in the frontend. But of course this does bypass the checks

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ] 
Go to page 1, 2  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu