Changeset c3d87d4cfed0d62d1df83e9ca20b17a56fb30ccc

Show
Ignore:
Timestamp:
04/29/10 19:39:54 (4 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1272569994 +0000
git-parent:

[70fa1f169d2fec3321b7fa5733ab3ff3df76bbdc]

git-author:
Mark Harrison <mark@omniti.com> 1272569994 +0000
Message:

Fix for when snapshots are present

The method used has also changed to use zpool list then zfs list on individual
filesystems. This is because zfs list can be very slow if there are a lot
of filesystems present.

git-svn-id: https://labs.omniti.com/resmon/branches/resmon2@338 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Core/ZpoolFree.pm

    r70fa1f1 rc3d87d4  
    3636case where zpool list does not report the correct values for monitoring. 
    3737 
     38Zpool list is still used to get the list of pools on the system, and then zfs 
     39list is run individually for each pool. This is done to improve performance in 
     40the case where there are many filesystems. 
     41 
    3842=head1 CONFIGURATION 
    3943 
     
    4751 
    4852Specify an alternative location for the zfs command. Default: /sbin/zfs. 
     53 
     54=item zpool_path 
     55 
     56Specify an alternative location for the zpool command. Default: /sbin/zpool. 
    4957 
    5058=back 
     
    9199    my $config = $self->{config}; # All configuration is in here 
    92100    my $zfs_command = $config->{zfs_command} || "/sbin/zfs"; 
     101    my $zpool_command = $config->{zpool_command} || "/sbin/zpool"; 
    93102    my $status = {}; 
    94     my $output = run_command("$zfs_command list -H -o name,used,avail"); 
    95     foreach my $line (split /\n/, $output) { 
    96         my ($name, $used, $uunit, $free, $funit) = $line =~ 
     103    my $output = run_command("$zpool_command list -H -o name"); 
     104    foreach my $pool (split /\n/, $output) { 
     105        # Sanity check in case zpool outputs something strange 
     106        die "Invalid pool name: $pool" if $pool !~ /[a-zA-Z0-9_.-]+/; 
     107        my $zfs_output = run_command( 
     108            "$zfs_command list -H -o name,used,avail $pool"); 
     109        my ($name, $used, $uunit, $free, $funit) = $zfs_output =~ 
    97110            /(\S+)\s+([0-9.]+)([BKMGTPEZ]?)\s+([0-9.]+)([BKMGTPEZ]?)/; 
    98111        # Make sure we were able to match the regex 
    99         die "Unable to parse zfs command output: $line\n" unless defined($name); 
     112        die "Unable to parse zfs command output: $zfs_output\n" 
     113            unless defined($name); 
    100114        next if ($name =~ /\//); # We're only interested in the root of a pool 
    101115