View unanswered posts    View active topics

All times are UTC - 6 hours





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

Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject:
PostPosted: Thu May 24, 2007 6:58 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
imstr8trippin wrote:
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.

I think you may need to do a join of recordmatch (for the start time) and program (for the length). The join keys are chanid and starttime. I haven't had time to get to this yet.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 8:32 am 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
tjc wrote:
imstr8trippin wrote:
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.

I think you may need to do a join of recordmatch (for the start time) and program (for the length). The join keys are chanid and starttime. I haven't had time to get to this yet.
I've augmented the script to use the inner join, but I'm not sure what you need the program length for. Here is the updated code.
Code:
#!/bin/sh

# initalize variables
db='mythconverg'
user='root'
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
                                inner join recordmatch on record.recordid=recordmatch.recordid
                                where timediff(recordmatch.starttime,sysdate())<'00:10:00' and
                                recordmatch.starttime > sysdate() and
                                inactive=0 and (type!=0 or type!=8);" -sN`

# Spit out warnings, if any and execute base on sql results
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

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 11:06 am 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
I found a flaw in my above script. It doesn't take into account the programs that have been marked as previously recorded, repeats.... but i'm not sure what the table is that contains that data. Is there somewhere that describes the purpose of each table?

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 7:03 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
There's something on the MythTV wiki, but it was fragmentary and shallow last time I checked. I used to check the SQL query logging in /var/log/mysql.log but that's apparently been disabled (at least out of the box) in this release. If you enable it and then go to the "Upcoming Recordings" page on MythWeb you should see something like the queries needed...


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 26, 2007 5:56 pm 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
Gnarl wrote:
I found a flaw in my above script. It doesn't take into account the programs that have been marked as previously recorded, repeats.... but i'm not sure what the table is that contains that data. Is there somewhere that describes the purpose of each table?


do you know for sure that the recordmatch table isn't already excluding things that you've specified as "do not record" ?

what i mean is, i thought the recordmatch table only contains data for recordings that WILL be recorded? if so, why would you need to know about previously recorded, repeats, etc.. ??

good work on the SQL statement, by the way. now, i don't need to do it myself. ;)

_________________
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: Sun May 27, 2007 7:25 am 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
tjc wrote:
There's something on the MythTV wiki, but it was fragmentary and shallow last time I checked. I used to check the SQL query logging in /var/log/mysql.log but that's apparently been disabled (at least out of the box) in this release. If you enable it and then go to the "Upcoming Recordings" page on MythWeb you should see something like the queries needed...
Tried this before, I think the scheduling is worked out but my myth's internal scheduler. The query i was able to pull while running mythbackend --testsched was about page long. and didn't work when entered alone.

imstr8trippin wrote:
do you know for sure that the recordmatch table isn't already excluding things that you've specified as "do not record" ?

what i mean is, i thought the recordmatch table only contains data for recordings that WILL be recorded? if so, why would you need to know about previously recorded, repeats, etc.. ??
I think all possible recordings are entered into the recordmatch table and the scheduler works out the kinks

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 1:35 pm 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
the data2 query should also join on the chanid field. recordmatch contains all channel matches for a scheduled recording:

Code:
data2=`mysql $db -u $user -e "select count(*) from record,recordmatch where \
        record.recordid=recordmatch.recordid and \
        record.chanid=recordmatch.chanid and \
        inactive=0 and (type!=0 or type!=8) and \
        timediff(recordmatch.starttime,now()) < '00:30:00' and \
        recordmatch.starttime > now();" -sN`


i haven't looked into the issue with program repeats, previously recorded, etc. yet, and i'm not sure if i ever will. it's a minor issue for me. this should result in a decent script to significantly better the odds of running mythfilldatabase when the system is not recording.

_________________
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 30, 2007 4:43 pm 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
more issues with this....

it looks like the recordmatch table is sometimes empty. i am assuming that the scheduler deletes all records and refreshes it sometimes. i think my mfdb script ran at a time when recordmatch was empty or missing some records because the script ran mythfilldatabase when it wasn't supposed to. i was thinking of adding some kind of check like the following:

Code:
data1=`mysql $db -u $user -e "select count(*) from record \
        left join recordmatch on \
        record.recordid=recordmatch.recordid and \
        record.chanid=recordmatch.chanid where \
        isNULL(recordmatch.recordid);" -sN`


if the query returns rows, there could be a scheduling discrepancy. but, i'm not sure if that will totally solve the problem. :?

_________________
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 31, 2007 2:41 pm 
Offline
Joined: Sat Mar 17, 2007 1:37 am
Posts: 32
OK...i think this finally does it. I wanted to get this done because the dropped frames issue has happened to me a few times...

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'
date=`date`
msgp="$date $script"

# 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=''

#command to execute mythfilldatabase
mfdb='mythfilldatabase --quiet'


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

sched=`mysql $db -u $user -e "select count(*) from record,recordmatch where \
        record.recordid=recordmatch.recordid and \
        record.chanid=recordmatch.chanid and \
        inactive=0 and (type!=0 or type!=8) and \
        timediff(recordmatch.starttime,now()) < '00:30:00' and \
        recordmatch.starttime > now();" -sN`

RM=`mysql $db -u $user -e "select count(*) from recordmatch;" -sN`

#lastrun=`mysql $db -u $user -e "select lastrun from housekeeping where \
#               tag='MythFillDB';" -sN`



if [ $rec -ge 1 ]; then
        echo "$msgp MythTV is recording a scheduled program.  \
        Please run mythfilldatabase at another time."


elif [ $sched -ge 1 ]; then
        echo "$msgp MythTV is scheduled to record a program shortly. \
        Please run mythfilldatabase at another time."


elif [ $RM -eq 0 ]; then
        echo "$msgp Recordmatch table is empty. Quitting"


else
        echo "$msgp MythTV will now run $mfdb"
        $mfdb
        exit 0

fi

# update housekeeping table with now() minus one day so mfdb will run again
updhousek=`mysql $db -u $user -e "update housekeeping \
                set lastrun=date_sub(now(),INTERVAL 1 DAY) \
                 where tag='MythFillDB';" -sN`




exit 12


i've added a check for the row count of recordmatch because the scheduler wipes it out and reloads it upon backend restart and an udpate to the housekeeping table so the script will run again before the following day, if mfdb didn't run.

i have this script setup for my mythfilldatabase command and the grabber updates my times to run it automagically. enjoy!

_________________
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  
 

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



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