Show snapshot usage
authorJamie Cameron <jcameron@webmin.com>
Thu, 24 Apr 2008 17:08:27 +0000 (17:08 +0000)
committerJamie Cameron <jcameron@webmin.com>
Thu, 24 Apr 2008 17:08:27 +0000 (17:08 +0000)
lvm/CHANGELOG
lvm/edit_lv.cgi
lvm/lang/en
lvm/lvm-lib.pl

index 5d6b931..c763f52 100644 (file)
@@ -10,3 +10,5 @@ Fixed display of space used on each physical volume by a logical volume for LVM
 Re-designed the module's main page to use tabs, and added an option to show volumes and groups in tables (with more information) instead of using icons.
 Converted all user interface code to use the new Webmin UI library.
 Fixed the command used to move data to another physical volume under LVM 2.
+---- Changes since 1.410 ----
+The percentage of a snapshot's blocks used is now shown on the Edit Snapshot page.
index a8e43ff..6f34236 100755 (executable)
@@ -78,6 +78,12 @@ if ($lv->{'is_snap'}) {
                    [ map { $_->{'name'} } grep { !$_->{'is_snap'} } @lvs ]);
                }
        print &ui_table_row($text{'lv_snapof'}, $snapsel);
+
+       # Show snapshot percentage used
+       if ($lv->{'snapusage'}) {
+               print &ui_table_row($text{'lv_snapusage'},
+                       $lv->{'snapusage'}."%");
+               }
        }
 elsif ($stat[2]) {
        # Display current permissons and allocation method
@@ -121,7 +127,7 @@ if (@stat && $stat[2]) {
                &nice_size($free*1024));
 
        print &ui_table_row($text{'lv_free'},
-               ($total ? 100 * $free / $total : 0)." %");
+               int($total ? 100 * $free / $total : 0)." %");
        }
 
 # Show extents on PVs
index 5970b4c..ac2123e 100644 (file)
@@ -88,6 +88,7 @@ lv_mountmsg=Mount this LV on new directory on your system, so that it can be use
 lv_free=Free percentage
 lv_freedisk=Free space
 lv_pvs=Physical volumes allocated
+lv_snapusage=Snapshot use percentage
 
 mkfs_title=Create Filesystem
 mkfs_desc=This form allows you to build a new $2 ($1) filesystem on logical volume $3. All existing data will be erased.
index 57b074a..f87f88f 100644 (file)
@@ -259,6 +259,16 @@ if (-d $lvm_proc) {
                $lv->{'is_snap'} = $p{'access'} == 5;
                $lv->{'stripes'} = $p{'stripes'};
                push(@rv, $lv);
+
+               # For snapshots, use the lvdisplay command to get usage
+               if ($lv->{'is_snap'}) {
+                       local $out = &backquote_command(
+                               "lvdisplay ".quotemeta($lv->{'device'}).
+                               " 2>/dev/null");
+                       if ($out =~/Allocated\s+to\s+snapshot\s+([0-9\.]+)%/i) {
+                               $lv->{'snapusage'} = $1;
+                               }
+                       }
                }
        closedir(DIR);
        }
@@ -298,6 +308,9 @@ else {
                elsif (/Stripes\s+(\d+)/) {
                        $lv->{'stripes'} = $1;
                        }
+               elsif (/Allocated\s+to\s+snapshot\s+([0-9\.]+)%/i) {
+                       $lv->{'snapusage'} = $1;
+                       }
                }
        close(DISPLAY);
        @rv = grep { $_->{'vg'} eq $_[0] } @rv;