From: Andrew Ruthven <andrew@etc.gen.nz>
Date: Tue, 11 Dec 2007 18:19:24 +0000 (+1300)
Subject: By default only show storage groups that are over the warning threshold.
X-Git-Tag: 0.6.0~7
X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c939c4231f8c8af850234b1c4b55b64c2709ca1;p=mythtv-status.git

By default only show storage groups that are over the warning threshold.
---

diff --git a/bin/mythtv-status b/bin/mythtv-status
index b94c17e..db72a53 100755
--- a/bin/mythtv-status
+++ b/bin/mythtv-status
@@ -256,7 +256,12 @@ my @blocks = (
     'commify' => [ qw/total used/ ],
     'template' => "Total space for group __id__ is __total__ GB, with __used__ GB used (__percent__)",
     'filter' =>  {
-      'id' => sub { return $_[0] eq 'total' }
+      'id' => sub { return $_[0] eq 'total' },
+      'used' => sub {
+        return ! (
+	  (defined $display{'Disk Space'} && $display{'Disk Space'})
+	    || ($_[1]->{'used'} / $_[1]->{'total'}) * 100 > $disk_space_warn)
+      }
     },
     'subs' => {
       'percent' => sub {
@@ -591,7 +596,7 @@ sub substitute_vars {
 
     $skip = 1
       if defined $block->{'filter'}{$key} &&
-        &{ $block->{'filter'}{$key} }($value);
+        &{ $block->{'filter'}{$key} }($value, $vars);
 
     if (defined $block->{'rewrite'}{"/$key/"}) {
       my ($search, $replace);
@@ -779,7 +784,9 @@ the next recording is displayed.
 
 =item Disk Space
 
-Details about each storage group that MythTV knows about.
+Details about each storage group that MythTV knows about.  By default this
+only shows storage groups that are above the warning level.  Use
+B<--disk-space> to turn on display of all storage groups.
 
 =back
 
diff --git a/testing/xml/multiple-storage-groups.pucks-patches.one-warn.xml b/testing/xml/multiple-storage-groups.pucks-patches.one-warn.xml
new file mode 100644
index 0000000..e3f8a8d
--- /dev/null
+++ b/testing/xml/multiple-storage-groups.pucks-patches.one-warn.xml
@@ -0,0 +1,15 @@
+<!DOCTYPE Status>
+<Status version="0.21.20071202-1" protoVer="36" xmlVer="1" ISODate="2007-12-07T16:26:55" time="4:26 PM" date="12/7/2007" >
+ <Encoders count="0" />
+ <Scheduled count="0" />
+ <JobQueue count="0" />
+ <MachineInfo>
+  <Storage>
+   <Group dir="cyclops:/home/andrew/myth6" free="18818" id="1" total="50396" used="31578" />
+   <Group dir="cyclops:/scratch/myth2,cyclops:/tmp/myth1,cyclops:/tmp/myth3,cyclops:/tmp/myth4" free="10644" id="2" total="20746" used="20101" />
+   <Group dir="TotalDiskSpace" free="29463" id="total" total="71143" used="41679" />
+  </Storage>
+  <Load avg1="0.04" avg2="0.1" avg3="0.19" />
+  <Guide status="" next="1970-01-01T00:00:00" end="" start="" ></Guide>
+ </MachineInfo>
+</Status>