NAME

Filesys::ZFS

SYNOPSIS

use Filesys::ZFS;

DESCRIPTION

Filesys::ZFS is a simple interface to zfs and zpool commands for managing ZFS file systems

METHODS

new(\%options)

Create a new Filesys::ZFS object and return it.

OPTIONS

Various options can be passed to the new() method

zpool

Path to the zpool command, defaults to /sbin/zpool

zfs

Path to the zfs command, defaults to /sbin/zfs

no_root_check

Don't warn if the calling program isn't root.

init()

Initialize. Read the various file system details. This method must be run prior to just about anything else working. If file system details change init() should be run again.

list(TYPE)

Returns an object list

TYPE

pools

Returns file system / Pools data (if any)

snapshots

Returns snapshots (if any)

volumes

Retruns volumes (if any)

bookmarks

Returns bookmarks (if any)

name()

Return the pool / snapshot / volume / bookmark name provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Pool: " . $pool->name . "\n";
    }

state()

Return the pool / snapshot / volume / bookmark state provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Current state: " . $pool->state . "\n";
    }

errors()

Return the pool / snapshot / volume / bookmark errors provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Current errors: " . $pool->errors . "\n";
    }

mount()

Return the pool / volume mount point (if available) provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Mount point: " . $pool->mount . "\n";
    }

scan()

Return the pool / volume scan message (if available) provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Last scan: " . $pool->scan . "\n";
    }

free()

Return the pool / volume free space (in KB) provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Free Space: " . $pool->free . "\n";
    }

used()

Return the pool / volume used space (in KB) provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Used Space: " . $pool->used . "\n";
    }

referenced()

Return the pool / volume referenced space (in KB) provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Referencing: " . $pool->referenced . "\n";
    }

status()

Return the pool / volume current status message provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Current status: " . $pool->status . "\n";
    }

action()

Return the pool / volume current action message provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Requested action: " . $pool->action . "\n";
    }

read()

Return the pool / volume read errors (if any) provided by the list() method

write()

Return the pool / volume write errors (if any) provided by the list() method

cksum()

Return the pool / volume checksum errors (if any) provided by the list() method

note()

Return the pool / volume error note (if any) provided by the list() method

config()

Return the pool / volume / snapshot / bookmark raw configuration message provided by the list() method

    for my $pool ($ZFS->list('pools')){
    	print "Configuration: " . $pool->config . "\n";
    }

providers()

The providers() method is intended to be called from a list() object initially, it returns a list of pool / volume providers, such as virtual devices or block devices.

The resulting list returned is a list of provider objects, which can be used to call the standard name(), read(), write(), cksum(), state() and note() methods defined above.

Additionally providers() can be called with a providers() object, allowing you to successully recruse through the providers stack. An example of this is as follows:

    prov($list_obj)
    
    sub prov {
           my ($p) = @_;
           for my $prov ($p->providers){
                   if($prov->is_vdev){
                           print "\tVirtual Device: " . $prov->name . "\n";
                           prov($prov);
                   } else {
                           print "\tBlock Device: " . $prov->name . "\n";
                   }
           }
    }

is_vdev(NAME)

Return true if the NAME device is a virtual device (vdev) of some kind or a regular block device or file

If NAME is omitted then the object name is used. This is useful when calling is_dev() from a providers() return:

is_health()

Return true if all zpools are in a healthy state. This can be called without initializing with init()

properties(POOL)

Return a list (in order) of all property keys for POOL, which can be a pool / file system / volume, etc.

propval(POOL, PROPERTY_KEY)

Return a two element list of the property value, and default for the property key PROPERTY_KEY in POOL pool / file system / volume.

errstr()

Return the last error string captured if any.

LICENSE

This library is licensed under the Perl Artistic license and may be used, modified, and copied under it's terms.

AUTHOR

This library was authorized by Colin Faber <cfaber@fpsn.net>. Please contact the author with any questions.

BUGS

Please report all bugs to https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=Filesys-ZFS