Oracle ZFS appliances provide a javascript-like scripting language that can be used to query the appliance. Here are 2 scripts that have come in very handy for me. Run using the script command.

Show space usage of shares

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fmt = '%-40s %-15s %-15s\n';
printf(fmt, 'SHARE', 'USED', 'AVAILABLE');
run('cd /');
run('shares');
pools = choices('pool');
for (p = 0; p < pools.length; p++) {
    set('pool', pools[p]);
    projects = list();
    for (i = 0; i < projects.length; i++) {
        run('select ' + projects[i]);
        shares = list();
        for (j = 0; j < shares.length; j++) {
            run('select ' + shares[j]);
            share = pools[p] + ':' + projects[i] + '/' + shares[j];
            printf(fmt, share, get('space_data'),
            get('space_available'));
            run('cd ..');
        }
    run('cd ..');
    }
}

Show status of services

1
2
3
4
5
6
7
8
9
10
11
configuration services
script
    var svcs = children();

    for (var i = 0; i < svcs.length; ++i) {
        run(svcs[i]);
        try {
            printf("%-10s %s\n", svcs[i], get('<status>'));
        } catch (err) { }
        run("done");
    }

Comments