The ztool

The ztool is a wordplay on 'zfs' and tool, and does a lot of work related to managing zfs filesystems. In that function, it is important for dealing with ZFS based storage infrastructures.

As any modern commandline tool, it is heavily based on the notion of 'subcommands', which makes them much easier to learn. Each subcommand may have its own set of subcommands along with its particular grammar.

Subcommands

report

As with the report subcommand of the itool, reports generated here are meant to provide you with ZFS specific information.Additionally, they may be used to generate script to delete snapshots based on various criteria.

All report commands require some configuration values, which can either be done in configuration files (see etc/ directory near executable) or via commandline overrides. These are indicated with '-s',

convert

The convert command takes zfs list or zpool list information as input and converts it into one ore more output formats. These are at the time of writing

This is already all it does, and it should be used in cron-jobs which pipe the output of zfs commands into respective tool invocation.

An example from real-world use could be as follows:

/usr/bin/ssh $host zpool list -o all -H | /path/to/ztool convert -sh $host -f $convert_mode -t sql-sync+graphite || exit $?

list

A simple tool to list the contents of the zfs information in the underlying SQL database, which can be information about pools, filesystems and snapshots. It allows you to define which columns to show per record using the -o flag, and by which column(s) to sort ascending (-s) or descending (-S).

A typical invocation could look like this:

ztool list pool -S cap

filesystem

The filesystem subcommands main purpose is to generate bash scripts to send one filesystem to another location as efficiently as possible, thus taking snapshots into accounts to only send deltas.

It operates on simple statements giving it a source and destination filesystem URL, and produces report-like output or a shell script.

It's used by the entire storage infrastructure, all snapshots are send using this functionality.

Here are some examples showing the main usecases:

# Show where the store filesystem on hostname would send its snapshots to
ztool filesystem sync zfs://hostname/store configured

# Find out good candidates to send a particular filesystem to
ztool filesystem sync zfs://hostname/store/projects/project-name -l

# generate a script to send a given filesystem to a specific location
ztool filesystem sync zfs://hostname/store/projects/project-name zfs://other-hostname/store/projects/project-name --script