[mythtv-users] LiveTV channel switching time

f-myth-users at media.mit.edu f-myth-users at media.mit.edu
Sat Dec 2 10:47:52 UTC 2006

    > Date: Sat, 2 Dec 2006 02:37:06 -0500
    > From: Chris Pinkham <cpinkham at bc2va.org>

    > > With your inuseprograms table and knowledge of which disks and
    > > encoders are in use, would it be possible to do these tasks
    > > when the system is quiet?

    > I believe so.  The housekeeper could do something like this:

    > void HouseKeeper::RunHouseKeeping(void)
    > {
    > ...
    >     if ((wantToRun("DailyDBTasks", 1, 0, 24)) &&
    >         (SystemIsIdle()))
    >     {
    >         RunExternalDailyDBTasksScript();
    >         updateLastrun("DailyDBTasks");
    >     }
    > ...
    > }

    > That way the backup/optimize never actually runs until the system is idle.
    > With this, it may make sense to include a script that does do the check,
    > optimize, and backup.  The name could be a setting if the user chose to
    > use their own, but otherwise we'd use the stock one.  Could probably take
    > advantage of or extend the perl bindings some for this.

    > Anything that is recording or in use by some form of playback should be in
    > the inuseprograms table.  The only notable exceptions that I know of
    > for this are MythArchive and nuvexport when it's not using mythtranscode.
    > That makes it easy to check whether we're idle or not.  That covers
    > the MythTV portion.  We know nothing about plugins, but we probably don't
    > care either.

Does this also manage to avoid system-about-to-become-nonidle?
E.g., you want to make sure the optimize/backup doesn't -start-
within some configurable time (on the order of a couple of minutes)
of when any encoder is -going- to be busy.  This requires at least
some interaction with the scheduler, but no more than MythWeb's
"Status" page has.

[In -my- case at least, btw, I don't care if playback is happening,
but that's probably because I only handle SD content.  I care very
much if recording is happening, though, because glitching that can't
be fixed.]

Assuming this is the case, this would have real utility, and I believe
I put something like this on the Feature Request page in the wiki a
few months ago.  I have a backup system that backs up the DB a few
times a day (keeping the last few backups for a couple days, and the
dailies for a few weeks, and the monthlies until we need the space---
the idea is to be able to recover from subtle corruption/goofs that
aren't discovered in a timely fashion).

The way I do this is to attempt to run several times a day, but to
skip a backup if the machine looks busy (by parsing MythWeb output to
see if any encoder is recording or will be recording "soon" or claims
to be recording in the next 10 minutes or less---this is critically
dependent upon exactly how MythWeb presents the output of this window,
and is a gross but effective kluge) because otherwise a backup is
likely to cause dropped video from encoders.  Something that's
better-integrated with -all- backends would be really nice, so that
optimization and dumping only happens when idle, and avoids having to
hand-parse MythWeb's output (yuck).

I also back up the backends (not recorded video, but everything -else-
on the host) via dirvish (basically a fancy rsync), and those runs
-also- skip running if it looks like the MBE's filesystem is already
busy handling encoders.  If Myth had a way of running an arbitrary
script when idle-and-will-be-idle-for-a-while, or just setting a flag
that could be checked via a simple script, then -that- backup system
also wouldn't have to parse MythWeb's output to know what was going on
with the backend.  (That requires knowing that the MBE will be idle
for on the order of 10 minutes into the future, since that's more than
the dirvish takes.  Easy enough when parsing MythWeb's output, of

NOTE that this second backup is run from the dirvish server, -NOT- the
backend (this is pretty much wired into the architecture of dirvish),
hence it can't get kicked off (directly) from a script run by any Myth
machine---that's why I made the comment above about "setting a flag"
or otherwise having something that can be interrogated to find out if
the machine is idle and will be idle for the next few minutes.

[If Myth tried to do this for me, but -didn't- happen when known to be
idle, I'd sure want a way to turn it off, because simply happening at
the same time(s) each day would be an excellent way of trashing
recordings, almost no matter what time was chosen, and -especially- if
it moved around with when DataDirect said was good to do a download.]

More information about the mythtv-users mailing list