]> git.etc.gen.nz Git - mythtv-status.git/commitdiff
Add support for reporting on how much guide data is present.
authorAndrew Ruthven <andrew@etc.gen.nz>
Wed, 12 Dec 2007 19:44:03 +0000 (08:44 +1300)
committerAndrew Ruthven <andrew@cerberus.etc.gen.nz>
Wed, 12 Dec 2007 19:44:03 +0000 (08:44 +1300)
ChangeLog
bin/mythtv-status
testing/xml/guide-data-1-day.xml [new file with mode: 0644]

index 4ce4b74f5758f3455cba406645b377a426ce1b77..2b01696876c553317e12966fb476b720eac60087 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-12-13     Andre Ruthven
+       Warn if there isn't enough guide data present.
+       
+2007-12-12     Andrew Ruthven
+       Release version 0.6.0
+
 2007-12-08     Andrew Ruthven
        Allow using my new xmlVer attribute in the XML.
        If using my XML patches against MythTV show the disk space details.
index db72a53708fe68498bdbf72dfd1f9e2e1f08e81e..3e8d23cb4a90f574e0b5d75f317112b394144388 100755 (executable)
@@ -30,6 +30,7 @@ my $help = undef;
 my $xml_file = undef;
 my $verbose = 0;
 my $disk_space_warn = 95;  # Percent to warn at.
+my $guide_days_warn = 2;   # How many days we require.
 
 my $VERSION = '0.6';
 
@@ -43,6 +44,7 @@ GetOptions(
   'email=s@'     => \@email,
   'email-only-on-conflict|email-only-on-alert' => \$email_only_on_alert,
   'disk-space-warn=i'      => \$disk_space_warn,
+  'guide-days-warn=i'      => \$guide_days_warn,
 
   'status!'               => \$display{'Status'},
   'encoders!'             => \$display{'Encoders'},
@@ -52,6 +54,7 @@ GetOptions(
   'next-recording!'       => \$display{'Next Recording In'},
   'total-disk-space!'     => \$display{'Total Disk Space'},
   'disk-space!'           => \$display{'Disk Space'},
+  'guide-data!'           => \$display{'Guide Data'},
 
   'file=s'                => \$xml_file,
 
@@ -298,6 +301,51 @@ my @blocks = (
     }
   },
 
+  # Check how much Guide data we have
+  {
+    'name'     => 'Guide Data',
+    'format'   => 'one line',
+    'type'     => 'xpath',
+    'xpath'    => '//Status/MachineInfo/Guide[@guideDays]',
+    'attrs'    => [qw/guideDays status guideThru/],
+    'template' => 'There is __guideDays__ days worth of data, through to __guideThru__',
+    'filter' => {
+      'guideDays' => sub {
+        if ($_[0] > $guide_days_warn) {
+         return
+           (defined $display{'Guide Data'} && ! $display{'Guide Data'}) || 1;
+        } else {
+          push @alerts, "GUIDE DATA";
+          return 0;
+        }
+      },
+    },
+    'rewrite'  => {
+      '&guideDays' => sub {
+        if ($_[0] <= $guide_days_warn) {
+          return "$warning$_[0]$normal";
+       } else {
+          return "$safe$_[0]$normal";
+        }
+      },
+      '/guideThru/' => { 'T\d+:\d+:\d+' => ' ' },
+      '&guideThru' => sub {
+        if ($_[1]->{'guideDays'} <= $guide_days_warn) {
+          return "$warning$_[0]$normal";
+       } else {
+          return "$safe$_[0]$normal";
+        }
+      },
+    },
+  },
+
+  {
+    'name'     => 'Guide Data',
+    'format'   => 'one line',
+    'type'     => 'xpath',
+    'xpath'    => '//Status/MachineInfo/Guide[@status=""]',
+    'template' => "${warning}No guide data!${normal}",
+  },
 );
 
 ###
@@ -603,8 +651,10 @@ sub substitute_vars {
       while (($search, $replace) = each %{ $block->{'rewrite'}{"/$key/"} } ) {
         $value =~ s/$search/$replace/g;
       }
-    } elsif (defined $block->{'rewrite'}{"&$key"}) {
-      $value = &{ $block->{'rewrite'}{"&$key"} }($value);
+    }
+
+    if (defined $block->{'rewrite'}{"&$key"}) {
+      $value = &{ $block->{'rewrite'}{"&$key"} }($value, $vars);
     }
 
     $value = commify($value)
@@ -722,11 +772,16 @@ Display help.
 Load XML from the file specified instead of querying a MythTV backend.
 Handy for debugging things.
 
+=item B<< --guide-data-warn <days> >>
+
+Warn if the number of days of guide data present is equal to or below
+this level.  Default is 2 days.
+
 =item B<-h HOST, --host=HOST>
 
 The host to check, defaults to localhost.
 
-=item B<--nostatus>, B<--noencoders>, B<--norecording-now>, B<--noscheduled-recordings>, B<--noschedule-conflicts>, B<--nonext-recording>, B<--nototal-disk-space>, B<--nodisk-space>
+=item B<--nostatus>, B<--noencoders>, B<--norecording-now>, B<--noscheduled-recordings>, B<--noschedule-conflicts>, B<--nonext-recording>, B<--nototal-disk-space>, B<--nodisk-space>, B<--noguide-data>
 
 Suppress displaying blocks of the output if they would normally be displayed.
 
@@ -756,6 +811,12 @@ The output of this script is broken up into several chunks they are:
 Some general info about the backend, currently just the timestamp of when
 this program was run.
 
+=item Guide Data
+
+The number of days of guide data is present.  By default it is only shown
+if the number of days is below the warning level.  To show it regardless
+of the warning level use --guide-data.
+
 =item Encoders
 
 Each encoder that the backend knows about are listed, with the hostname
diff --git a/testing/xml/guide-data-1-day.xml b/testing/xml/guide-data-1-day.xml
new file mode 100644 (file)
index 0000000..6f0df31
--- /dev/null
@@ -0,0 +1,71 @@
+<!DOCTYPE Status>
+<Status version="0.20.20070821-1" protoVer="31" time="6:43 PM" date="Thu Nov 29 2007" >
+ <Encoders count="2" >
+  <Encoder local="1" connected="1" id="9" state="4" hostname="cerberus" >
+   <Program programFlags="0" title="3 News" programId="" catType="tvshow" category="News" seriesId="55921891" endTime="2007-11-29T19:00:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-11-29T18:00:00" hostname="cerberus" >3 News<Channel chanFilters="" channelName="TV3" chanNum="3" sourceId="3" commFree="0" inputId="15" chanId="1002" callSign="TV3" />
+    <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="9" recEndTs="2007-11-29T19:00:00" recStatus="-2" recordId="20" recProfile="Default" recType="2" playGroup="Default" recPriority="2" recStartTs="2007-11-29T18:00:00" />
+   </Program>
+  </Encoder>
+  <Encoder local="1" connected="1" id="12" state="0" hostname="cerberus" />
+ </Encoders>
+ <Scheduled count="10" >
+  <Program programFlags="0" title="McLeod's Daughters" programId="" catType="series" category="Drama" seriesId="134400579" endTime="2007-11-29T21:30:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-11-29T20:30:00" hostname="" >Grace's pride won't let her admit it was her poor credit rating that led to the bank's refusal to extend their overdraft. She has to learn to work with Kate when they're taken hostage by a distraught<Channel chanFilters="" channelName="TV2" chanNum="2" sourceId="3" commFree="0" inputId="15" chanId="1001" callSign="TV2" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Keep" encoderId="9" recEndTs="2007-11-29T21:35:00" recStatus="-1" recordId="7" recProfile="Default" recType="4" playGroup="Default" recPriority="12" recStartTs="2007-11-29T20:25:00" />
+  </Program>
+  <Program programFlags="0" title="30 Rock" programId="" catType="tvshow" category="General Show" seriesId="103126443" endTime="2007-11-29T22:35:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-11-29T22:05:00" hostname="" >Named Best New Comedy by American TV Guide<Channel chanFilters="" channelName="TV3" chanNum="3" sourceId="3" commFree="0" inputId="15" chanId="1002" callSign="TV3" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="9" recEndTs="2007-11-29T22:35:00" recStatus="-1" recordId="449" recProfile="Default" recType="4" playGroup="Default" recPriority="2" recStartTs="2007-11-29T22:05:00" />
+  </Program>
+  <Program programFlags="0" title="3 News" programId="" catType="tvshow" category="News" seriesId="55921891" endTime="2007-11-30T19:00:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-11-30T18:00:00" hostname="" >3 News<Channel chanFilters="" channelName="TV3" chanNum="3" sourceId="3" commFree="0" inputId="15" chanId="1002" callSign="TV3" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="9" recEndTs="2007-11-30T19:00:00" recStatus="-1" recordId="20" recProfile="Default" recType="2" playGroup="Default" recPriority="2" recStartTs="2007-11-30T18:00:00" />
+  </Program>
+  <Program programFlags="0" title="Boston Legal" programId="" catType="series" category="Comedy" seriesId="82056732" endTime="2007-11-30T22:30:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-11-30T21:30:00" hostname="" >A gripping drama series starring Emmy Award-winners James Spader and William Shatner along with a stellar support cast including Rhona Mitra<Channel chanFilters="" channelName="TV3" chanNum="3" sourceId="3" commFree="0" inputId="15" chanId="1002" callSign="TV3" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="9" recEndTs="2007-11-30T22:30:00" recStatus="-1" recordId="100" recProfile="Default" recType="9" playGroup="Default" recPriority="3" recStartTs="2007-11-30T21:30:00" />
+  </Program>
+  <Program programFlags="0" title="The Apprentice" programId="" catType="tvshow" category="General Show" seriesId="114371909" endTime="2007-12-01T13:00:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-12-01T12:00:00" hostname="" >The teams must create a 60-second promotional video for new Microsoft software, with execs from the technology giant as the final judges. With only two people left on each team, the stakes are high.<Channel chanFilters="" channelName="TV2" chanNum="2" sourceId="3" commFree="0" inputId="15" chanId="1001" callSign="TV2" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="9" recEndTs="2007-12-01T13:00:00" recStatus="-1" recordId="69" recProfile="Default" recType="3" playGroup="Default" recPriority="2" recStartTs="2007-12-01T12:00:00" />
+  </Program>
+  <Program programFlags="0" title="3 News" programId="" catType="tvshow" category="News" seriesId="55921891" endTime="2007-12-01T19:00:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-12-01T18:00:00" hostname="" >3 News<Channel chanFilters="" channelName="TV3" chanNum="3" sourceId="3" commFree="0" inputId="15" chanId="1002" callSign="TV3" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="9" recEndTs="2007-12-01T19:00:00" recStatus="-1" recordId="20" recProfile="Default" recType="2" playGroup="Default" recPriority="2" recStartTs="2007-12-01T18:00:00" />
+  </Program>
+  <Program programFlags="0" title="Grand Designs" programId="" catType="tvshow" category="General Show" seriesId="71416915" endTime="2007-12-01T20:30:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-12-01T19:30:00" hostname="" >Grand Designs<Channel chanFilters="" channelName="TV3" chanNum="3" sourceId="3" commFree="0" inputId="15" chanId="1002" callSign="TV3" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="9" recEndTs="2007-12-01T20:30:00" recStatus="-1" recordId="450" recProfile="Default" recType="4" playGroup="Default" recPriority="2" recStartTs="2007-12-01T19:30:00" />
+  </Program>
+  <Program programFlags="0" title="3 News" programId="" catType="tvshow" category="News" seriesId="55921891" endTime="2007-12-02T19:00:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-12-02T18:00:00" hostname="" >3 News<Channel chanFilters="" channelName="TV3" chanNum="3" sourceId="3" commFree="0" inputId="15" chanId="1002" callSign="TV3" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="9" recEndTs="2007-12-02T19:00:00" recStatus="-1" recordId="20" recProfile="Default" recType="2" playGroup="Default" recPriority="2" recStartTs="2007-12-02T18:00:00" />
+  </Program>
+  <Program programFlags="0" title="Property Climbers" programId="" catType="tvshow" category="General Show" seriesId="240103315" endTime="2007-12-02T19:30:00" lastModified="2007-11-29T07:49:55" subTitle="" stars="0" repeat="0" fileSize="0" startTime="2007-12-02T19:00:00" hostname="" >Two friends take the property-coaching route to riches; and a young couple mortgages their home to the hilt and goes without, to make their fortune.<Channel chanFilters="" channelName="TV1" chanNum="1" sourceId="7" commFree="0" inputId="17" chanId="8035" callSign="TV1" />
+   <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="12" recEndTs="2007-12-02T19:40:00" recStatus="-1" recordId="194" recProfile="Default" recType="3" playGroup="Default" recPriority="0" recStartTs="2007-12-02T19:00:00" />
+  </Program>
+ </Scheduled>
+ <JobQueue count="6" >
+  <Job status="1" flags="0" cmds="0" type="2" chanId="1004" args="" id="1062" insertTime="2006-06-18T19:05:02" statusTime="2006-06-18T19:05:02" startTime="2006-06-18T18:00:00" hostname="master" startTs="20060618180000" ><Program programFlags="0" title="Scrapheap Challenge" programId="" catType="" category="" seriesId="102271877" endTime="2006-06-18T19:00:00" airdate="2006-06-18" lastModified="2007-02-21T21:19:37" subTitle="" stars="0" repeat="0" fileSize="2512355768" startTime="2006-06-18T18:00:00" hostname="cerberus" >Two teams take on the challenge to construct a super fast monster machine at least 5 metres long and weighing at least 5.5 tonnes.<Channel chanFilters="" channelName="Prime" chanNum="5" sourceId="0" commFree="0" inputId="0" chanId="1004" callSign="Prime" />
+    <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="0" recEndTs="2006-06-18T19:05:00" recStatus="-3" recordId="57" recProfile="Default" recType="0" playGroup="Default" recPriority="1" recStartTs="2006-06-18T18:00:00" />
+   </Program>
+  </Job>
+  <Job status="1" flags="0" cmds="0" type="2" chanId="1004" args="" id="1077" insertTime="2006-06-25T19:05:02" statusTime="2006-06-25T19:05:02" startTime="2006-06-25T18:00:00" hostname="master" startTs="20060625180000" ><Program programFlags="0" title="Scrapheap Challenge" programId="" catType="" category="" seriesId="102271877" endTime="2006-06-25T19:00:00" airdate="2006-06-25" lastModified="2007-02-21T21:19:37" subTitle="" stars="0" repeat="0" fileSize="2513114516" startTime="2006-06-25T18:00:00" hostname="cerberus" >Classic car nuts, the Beasts of Bodmin, take on Essex forklift trio, The Powerlifters in one of the hardest challenges to date: making cars that can clamber over boulders.<Channel chanFilters="" channelName="Prime" chanNum="5" sourceId="0" commFree="0" inputId="0" chanId="1004" callSign="Prime" />
+    <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="0" recEndTs="2006-06-25T19:05:00" recStatus="-3" recordId="57" recProfile="Default" recType="0" playGroup="Default" recPriority="1" recStartTs="2006-06-25T18:00:00" />
+   </Program>
+  </Job>
+  <Job status="1" flags="0" cmds="0" type="2" chanId="1004" args="" id="1105" insertTime="2006-07-09T19:05:02" statusTime="2006-07-09T19:05:02" startTime="2006-07-09T18:00:00" hostname="master" startTs="20060709180000" ><Program programFlags="0" title="Scrapheap Challenge" programId="" catType="" category="" seriesId="102271877" endTime="2006-07-09T19:00:00" airdate="2006-07-09" lastModified="2007-02-21T21:19:37" subTitle="" stars="0" repeat="0" fileSize="2511276800" startTime="2006-07-09T18:00:00" hostname="cerberus" >A collection of favourite clips from the engineering entertainment show that pits teams of madcap mechanics against each other.<Channel chanFilters="" channelName="Prime" chanNum="5" sourceId="0" commFree="0" inputId="0" chanId="1004" callSign="Prime" />
+    <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="0" recEndTs="2006-07-09T19:05:00" recStatus="-3" recordId="57" recProfile="Default" recType="0" playGroup="Default" recPriority="1" recStartTs="2006-07-09T18:00:00" />
+   </Program>
+  </Job>
+  <Job status="1" flags="0" cmds="0" type="2" chanId="1004" args="" id="1873" insertTime="2007-09-24T21:35:00" statusTime="2007-09-24T21:35:00" startTime="2007-09-24T20:30:00" hostname="master" startTs="20070924203000" ><Program programFlags="20" title="Mythbusters" programId="" catType="" category="" seriesId="161457779" endTime="2007-09-24T21:30:00" airdate="2007-09-24" lastModified="2007-10-28T22:15:06" subTitle="" stars="0" repeat="0" fileSize="2511779108" startTime="2007-09-24T20:30:00" hostname="cerberus" >Adam and Jamie try to beat a heat-detecting alarm sensor, attempt to crack a door guarded by fingerprint technology and crack a safe only opened by an underwater explosion.<Channel chanFilters="" channelName="Prime" chanNum="5" sourceId="0" commFree="0" inputId="0" chanId="1004" callSign="Prime" />
+    <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="0" recEndTs="2007-09-24T21:35:00" recStatus="-3" recordId="154" recProfile="Default" recType="0" playGroup="Default" recPriority="0" recStartTs="2007-09-24T20:30:00" />
+   </Program>
+  </Job>
+  <Job status="1" flags="0" cmds="0" type="2" chanId="1004" args="" id="1896" insertTime="2007-10-08T21:35:01" statusTime="2007-10-08T21:35:01" startTime="2007-10-08T20:30:00" hostname="master" startTs="20071008203000" ><Program programFlags="4" title="Mythbusters" programId="" catType="" category="" seriesId="161457779" endTime="2007-10-08T21:30:00" airdate="2007-10-08" lastModified="2007-10-08T21:35:00" subTitle="" stars="0" repeat="0" fileSize="2511648476" startTime="2007-10-08T20:30:00" hostname="cerberus" >Jamie and Adam play with high-speed wind and find out whether the wind in a hurricane can get strong enough to blow a piece of straw through a palm tree trunk and blow the feathers off a chicken.<Channel chanFilters="" channelName="Prime" chanNum="5" sourceId="0" commFree="0" inputId="0" chanId="1004" callSign="Prime" />
+    <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="0" recEndTs="2007-10-08T21:35:00" recStatus="-3" recordId="154" recProfile="Default" recType="0" playGroup="Default" recPriority="0" recStartTs="2007-10-08T20:30:00" />
+   </Program>
+  </Job>
+  <Job status="1" flags="0" cmds="0" type="2" chanId="1004" args="" id="1910" insertTime="2007-10-15T21:35:00" statusTime="2007-10-15T21:35:00" startTime="2007-10-15T20:30:00" hostname="master" startTs="20071015203000" ><Program programFlags="4" title="Mythbusters" programId="" catType="" category="" seriesId="161457779" endTime="2007-10-15T21:30:00" airdate="2007-10-15" lastModified="2007-10-15T21:35:00" subTitle="" stars="0" repeat="0" fileSize="2509824968" startTime="2007-10-15T20:30:00" hostname="cerberus" >Jamie and Adam try to prove that a cable snapping at high tension can slice a person in half, while the others explore the theory that pottery contains sounds that can be played back like a record.<Channel chanFilters="" channelName="Prime" chanNum="5" sourceId="0" commFree="0" inputId="0" chanId="1004" callSign="Prime" />
+    <Recording dupInType="15" dupMethod="6" recGroup="Default" encoderId="0" recEndTs="2007-10-15T21:35:00" recStatus="-3" recordId="154" recProfile="Default" recType="0" playGroup="Default" recPriority="0" recStartTs="2007-10-15T20:30:00" />
+   </Program>
+  </Job>
+ </JobQueue>
+ <MachineInfo>
+  <Storage _local_free="28420" _total_total="102350" slaves="_local,_total" _total_used="73929" _total_free="28420" _local_total="102350" _local_used="73929" />
+  <Load avg1="0.93" avg2="1.08" avg3="1.14" />
+  <Guide guideDays="1" status="Successful." next="1970-01-01T00:00:00" end="2007-11-29 07:49" guideThru="2007-12-30T00:00:00" start="2007-11-29 07:49" ></Guide>
+ </MachineInfo>
+</Status>